LIST MEMBERSHIP TEST IN PYTHON

GOCOURSE



List Membership Test

Checking the membership test and iterating over the list are two other list operations. Using the keyword "in," we can verify that an element is present in the list. It returns a true or false boolean value.

Program: 1


Mylist=['apple', 'banana', 'guava','kiwi']
Print('apple' in Mylist)



Output:


True


Program: 2


Mylist=['apple', 'banana', 'guava','kiwi']
Print('orange' in Mylist)

 


Output:


False




More topic in Python

Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send