Programming-Idioms

History of Idiom 42 > diff from v37 to v38

Edit summary for version 38 :
Restored version 34

Version 37

2019-11-18, 14:38:51

Version 38

2019-11-18, 20:06:18

Idiom #42 Continue outer loop

Print each item v of list a which in not contained in list b.
For this, write an outer loop to iterate on a and an inner loop to iterate on b.

Illustration

Idiom #42 Continue outer loop

Print each item v of list a which in not contained in list b.
For this, write an outer loop to iterate on a and an inner loop to iterate on b.

Illustration
Code
import time
import os
import sys
import random



def leaderboard():
    board = open("results.txt", "r")
    boardr = board.read()
    print(boardr)


def write_file():
    space = " "
    newline = "\n"
    collon = ":"
    score = "score = "
    results = open("results.txt", "a")
    results.write(newline)
    results.write(namecheck)
    results.write(collon)
    results.write(space)
    results.write(score)
    results.write(count)
    sys.exit(0)

def userauth():
    global namecheck
    u
Code
for v in a:
    try:
        for u in b:
            if v == u:
                raise Exception()
        print(v)
    except Exception:
        continue
Comments bubble
Note that using two loops like this in python is by itself very un-idiomatic. Also one would be wise to define a custom exception to avoid hiding "real" exceptions.
Comments bubble
Note that using two loops like this in python is by itself very un-idiomatic. Also one would be wise to define a custom exception to avoid hiding "real" exceptions.