Logo

Programming-Idioms

History of Idiom 42 > diff from v35 to v36

Edit summary for version 36 by sadasdas:
[Python] dfdsf

Version 35

2019-11-18, 14:37:23

Version 36

2019-11-18, 14:38:21

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
for v in a:dsasddasdasdasdasd
    try:
        for u in b:
            if v == u:
                raise Exception()
        print(v)
    except Exception:
        continue
Code
sdfds
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.