Membership operator - "in":
-
The in operator called on a dictionary instance tests whether a given key is contained in a dictionary.
-
If the value is present in the sequence it returns True. It returns False otherwise.
Example 1:
# Example Python program that uses if 'path' in environmentDictionary: |
Output:
Path is set |
Example 2:
# Example Python program that checks fruitPrices = {"Apples":1.42, fruit2Lookup = "Grapes"; if fruit2Lookup in fruitPrices: |
Output:
Grapes not available |