Python ProgrammingPython Programming

How to check if Item exists in list in python?

To verify if a specified item is exist in a list use the in keyword.

Check if "Japan" exist in the list:

testList = ["Canada", "Japan", "London", "Germany", "Africa"]
 
if "Japan" in testList:
    print("Yes")
Output
Yes