Python controleren of lijstitem bestaat
Controleren of lijstitem bestaat
Gebruik het in
trefwoord om te bepalen of een bepaald item in een lijst voorkomt:
Voorbeeld
Controleer of "appel" in de lijst voorkomt:
thislist = ["apple", "banana", "cherry"]
if "apple" in thislist:
print("Yes, 'apple' is in the fruits list")