Home >Backend Development >Python Tutorial >What does in in python mean?
in is an operator in Python, specifically a member operator. It is to make member judgments for data types such as sequences (strings, tuples, lists) or sets (sets) or maps (dictionaries). The natural member judgment returns whether it is in or not among them. In Python terms, it is True, False. That is to say, xxinxxx can be used in typical situations that require judgment, such as: if xx in xxx, while xx in xxx, etc. (not only that, there are more).
The code is as follows:
a = 1 b = (1,2,3) c = [1,2,3] d = {1:"a",2:"b",c:"3"} e = {1,2,3} f = "123" if a in b: do something . . . if a in f: do something #完全 do 不了,因为不在其中。。。
As a member operator, it is combined with another keyword not to form a non-member judgment that cannot be more elegant: it is not among them.
The code is as follows:
if a not in f; do something
For more Python-related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of What does in in python mean?. For more information, please follow other related articles on the PHP Chinese website!