Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...

Code Snippet

#create a dictionary to store teacher's details
d={"Name": "Mr Moose","Subject": "Philosophy","Hobby":"Chess","School House":"Red House"}

def main():
   key=input("Enter Key you are looking for:")
   if key in d:
       print("Yep, we have that key in the dictionary")
        print("Nope - doesn't exist in the dictionary, sorry!")

Try it yourself