a = ['1', 'a', '3', 'c'], ['e', 't', 'h', '3'], ['u', 'y', 'p', '2']
b = ['u', 'y', 'p', '2'], ['4', 's', 'a', 'x'], ['8', '9', 'y', 'w']
q = [w for w, s in zip(a, b) if 'a' not in (w and s)]
e = [s for w, s in zip(a, b) if 'a' not in (w and s)]
print(q)
print(e)
I'd like to select only the list with 'a' in it and the list without that pair
I thought it would be possible to use the not in operator and the and operator, but... The list without 'a' and its pair were removed from the b list only
I would like to express my gratitude to those who help me!
python list list-comprehension
if 'a' not in w + s
© 2024 OneMinuteCode. All rights reserved.