Logo

Programming-Idioms

History of Idiom 42 > diff from v29 to v30

Edit summary for version 30 by sgdpk:
New Python implementation by user [sgdpk]

Version 29

2017-06-05, 15:53:59

Version 30

2019-09-27, 03:11:50

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

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