Membership Operators in Python (IN, NOT IN)

🎓 Welcome back to Digital Academy, the Complete Python Development Tutorial for Beginners, which will help you Learn Python from A to Z!

🖥️ Types of Operators in Python – Membership Operators in Python

Depending upon the type of operations you want to perform, there are 7 types of operators in Python: Arithmetic operators, Assignment operator, Comparison operators, Logical operators, Bitwise operators, Identity operators and Membership operators.

○ Membership Operators in Python – IN, NOT IN

Membership Operators, “in” and “not in”, are used to test whether a value, or variable, is found in a sequence: String, List, Tuple, Set or Dictionary. Following are the Membership Operators that we have in Python, and return a boolean.

Operator | Meaning | Example
in | True if value/variable is found in the sequence | 5 in x
not in | True if value/variable is not found in the sequence | 5 not in x

For instance, if a value 3 is found in the list X=[1, 2, 3, 4, 5], the statement “3 in X” will return True. BUT, on the other hand, the statement “3 not in X” will return False, since 3 is not an element of this list. Following are a few examples:

x = 'Hello world'
y = {1:'a', 2:'b'}

OUTPUT
'H' in x True
'hello' not in x True
print(1 in y) True
print('a' in y) False


Let’s play this video, stick around and watch until the end of this video! 👍🏻

– Digital Academy™ 🎓

***

☞ WATCH NEXT:
○ Data Types in Python – https://youtu.be/cweUByxBWiU
○ Operators in Python – https://youtu.be/-wDaVLkKOiU
○ IF Statements in Python – https://youtu.be/CC5seZ6OBJ4
○ FOR Loops in Python – https://youtu.be/JgH-D5DSTho

☞ WATCH MORE:
○ HOW TO Learn Python? Python Tutorial for Beginners [FULL Course] https://youtu.be/9hvnSZPMtuw

📖 Blog: http://digital.academy.free.fr/blog/

📖 Complete Python Development Course for Beginners [PLAYLIST]: http://digital.academy.free.fr/playlist/python-development-for-beginners

🛒 Shopping and Discounts: http://digital.academy.free.fr/store/

#Python #Tutorial #Beginners #Shorts

***

♡ Thanks for watching and supporting ♡
Please Subscribe. Hit the notification bell.
Like, Comment and Share.

***

♡ FOLLOW US ♡
http://digital.academy.free.fr/
https://twitter.com/DigitalAcademyy
https://www.facebook.com/digitalacademyfr
https://www.instagram.com/digital_academy_fr/
https://www.youtube.com/c/DigitalAcademyOnline

♡ SUPPORT US ♡
http://digital.academy.free.fr/join
http://digital.academy.free.fr/donate
http://digital.academy.free.fr/subscribe
https://www.patreon.com/digital_academy
https://www.buymeacoffee.com/digital_academy

***

Copy link
Powered by Social Snap