I have the following tuple :
mytuple = (("azerty", "1"), ("qwerty", "2"))
I am trying to check if a variable is not in it:
n = 'azerty'
if n not in mytuple:
print('not in the list')
> not in the list
I am trying to match the string "azerty" to each tuple in the tuple, So I tried to go 1 more layer into the tuple:
for mylist in mytuple:
if n not in mylist:
print('not in the list')
> not in the list
Now the problem here is mytuple[1]
is matching my if, making me print.
Do you know how can I check if my variable is not in a tuple?
EDIT: This question was marked as duplicate. However, the answered post refers to a slightly different problem. The original post checks existence by index and this problem wants to check existence for any element in the tuple.