Python How to Check for an item in a Tuple

preview_player
Показать описание
Python How to Check for an item in a Tuple
Check whether an element exists within a tuple
How to check if a tuple contains an element
Search
tuple1 = [2,4,5,8,1]
if 8 in tuple1:
print "tuple1 contains 8"
if 3 not in tuple1:
print "tuple1 doesn't contain 3"
if tuple1.__contains__(5):
print "tuple1 contains 5"
Рекомендации по теме
welcome to shbcf.ru