Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Dictionary basics
Dictionaries in loops and conditional statements
8. The in operator
Dictionaries in functions
Summary

Instruction

Nicely done! Do you remember how we used the in/not in operators with lists? They work exactly the same with dictionaries! The in and not in operators check if the given key is present in the dictionary. Take a look:

# define a dictionary
# check if Shakira is there
if 'Shakira' in phonebook:
  print('Yay, we have Shakira\'s number!')
else:
  print('Shakira not found :(')

Exercise

Ask the user to provide an integer: Enter a year between 2000 and 2018 to check if there was a major Windows release.

If there is an item for the given year in os_releases, print: A major version found: {os_release}.

Otherwise, print: No major version found.

Stuck? Here's a hint!

In the conditional statement, use:

if user_input in os_releases: