Python Check If List Item Exists
Check If List Item Exists
To determine if a specified item is present in a list use the in
keyword:
Example
Check if "apple" is present in the list:
thislist = ["apple", "banana", "cherry"]
if "apple" in thislist:
print("Yes, 'apple' is in the fruits list")
Try it Yourself »
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.