Name

in

Examples

# Check if a given substring is present in a string
message = "Now is the winter of our discontent."
print("winter" in message) # Prints 'True'

# Check if an item is present in a list
data = [17, 24, 32, 912, 403]
print(17 in data) # Prints 'True'

# Check if a key is present in a dictionary
elements = {'H': 'hydrogen', 'He': 'helium', 'Li': 'lithium'}
print('He' in elements) # Prints 'True'

# Note: The "in" operator doesn't check for *values* in dictionaries!
print('hydrogen' in elements) # Prints 'False'

Description
Syntax
	item in object
Parameters
i
a
Related list()
string
Dictionary
Updated on Wed Jan 18 17:32:20 2017.
Creative Commons License