Python Membership and Identity Operators - Learn Python Programming - APPFICIAL

preview_player
Показать описание
It’s a pretty common task to check if a value is found within a container, such as a list or dictionary. In python, you can use a membership operator to find that out.

You can use membership operators to check if a substring is found within a string. Ex. ‘cat' in ‘caterpillar' returns True.

Membership in a dictionary checks if a specific key exists in the dictionary.

You may want to determine if two variables are the same object. Use the identity operator, is, to check if two operands are bound to a single object. There is also the is not operator which checks if something is not the same object, and returns True if they’re not.

Identity operators do not compare the value of the two objects, but rather the objects memory address location in memory to see if they’re the same or not. There is an id() function which returns the identity of an object.

Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!
Рекомендации по теме
Комментарии
Автор

Can you please make a video about for i in range, and functions. BTW your videos are very helpful!

annastasia
welcome to shbcf.ru