-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphoneDirectory.program.py
More file actions
39 lines (24 loc) · 916 Bytes
/
phoneDirectory.program.py
File metadata and controls
39 lines (24 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
phone_directory = {}
def add_contact(name, number):
if name in phone_directory:
print(f"{name} is already in the directory.")
else:
phone_directory[name] = number
print(f"{name} has been added to the directory.")
def search_contact(name):
if name in phone_directory:
print(f"{name}'s number is {phone_directory[name]}.")
else:
print(f"{name} is not in the directory.")
def delete_contact(name):
if name in phone_directory:
phone_directory.pop(name)
print(f"{name} has been deleted from the directory.")
else:
print(f"{name} is not in the directory.")
n=int(input('how many numbers do you want to enter'))
for i in range(n):
user_input=input('Enter the name and number')
name,number=user_input.split(':')
phone_directory[name]=number
print(phone_directory)