How to check if a tuple contains an element in Python?
if "word" in str(tuple):
# You can convert the tuple to str too
i has the same problem and only worked to me after the convert str()
Be careful with that: return Oops. use Set: d= {...}
def simha():
d = ('this_is_valid')
b = 'valid'
if b in d:
print("Oops!!!!!")
simha()
You use in
.
if element in thetuple:
#whatever you want to do.