Python List Compensation. Here'

Asked 2 years ago, Updated 2 years ago, 76 views

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

2022-09-20 11:15

1 Answers

if 'a' not in w + s


2022-09-20 11:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.