Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import exit
- # a dictionary has keys and values, names and numbers in this case
- # could be words and definition
- people = {
- "Lucio": "617-868-8543",
- "Jackie": "617-876-9580",
- "Matthew": "617-864-2838",
- "Jacob": "617-519-3820",
- }
- if "Jacob" in people:
- print(f"Found {people['Jacob']}") # will print the value that was associated with the string jacob
- exit(0)
- else:
- print("not found")
- for person in people: ## this does not work... ask reddit how i might print every item in dictionary
- #print(person)
- print(" {people['jackiie']} prints")
- # pythonic way of asking if a value is in the dictionary
- # you can treat it like an array where instead of the indices are numbers, the indices are words
- # key value pairs keys are strings
Advertisement
Add Comment
Please, Sign In to add comment