Programming-Idioms

History of Idiom 42 > diff from v38 to v39

Edit summary for version 39 :
Admin deletes impl 3168: Wrong

Version 38

2019-11-18, 20:06:18

Version 39

2019-11-29, 22:15:31

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:
    for v_ in b:
        if v == v_:
            continue
        print(v)

# More idiomatic solution for this specific problem
# 
# for v in a:
#     if v not in b:
#        print(v)