-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (42 loc) · 1.3 KB
/
main.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from tabulate import tabulate
contact_dict = {}
def add_contact():
name = input("Enter contact name")
number = input("Enter contact number")
email = input("Enter contact email")
contact_dict.update({name:(number,email)})
def view_contact():
print(tabulate(contact_dict.items(), headers=["Contact Name", "Contact Details"]))
def search_contact():
s_name = input("Enter name of contact that you want to search")
if s_name in contact_dict:
print("Contact is present in dictionary")
print(contact_dict[s_name])
else:
print("Contact not present")
def delete_contact():
d_name = input("Enter name of contact that you want to delete")
contact_dict.pop(d_name)
def show_menu():
print("Press 1 to add contact")
print("Press 2 to view contact")
print("Press 3 to search contact")
print("Press 4 to delete contact")
print("Press 5 to exit")
def main():
show_menu()
while True:
choice = int(input("Enter your choice"))
if choice == 1:
add_contact()
elif choice == 2:
view_contact()
elif choice == 3:
search_contact()
elif choice == 4:
delete_contact()
elif choice == 5:
break
else:
print("Invalid Choice")
main()