19 lines
457 B
Python
19 lines
457 B
Python
# Implements a phone book as a list of dictionaries, without a variable
|
|
|
|
from cs50 import get_string
|
|
|
|
people = [
|
|
{"name": "Carter", "number": "+1-617-495-1000"},
|
|
{"name": "David", "number": "+1-617-495-1000"},
|
|
{"name": "John", "number": "+1-949-468-2750"},
|
|
]
|
|
|
|
# Search for name
|
|
name = get_string("Name: ")
|
|
for person in people:
|
|
if person["name"] == name:
|
|
print(f"Found {person['number']}")
|
|
break
|
|
else:
|
|
print("Not found")
|