Python Controleer of Tuple-item bestaat
Controleer of Tuple-item bestaat
Gebruik het in
trefwoord om te bepalen of een bepaald item in een tuple aanwezig is:
Voorbeeld
Controleer of "appel" aanwezig is in de tuple:
thistuple = ("apple", "banana", "cherry")
if "apple" in thistuple:
print("Yes, 'apple' is in the fruits tuple")