-
Notifications
You must be signed in to change notification settings - Fork 1
/
Contacts .py
134 lines (107 loc) · 3.56 KB
/
Contacts .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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
database = {"shuttle":9080590855,"barath":638383877,"hannah":6987237898}
print("\nGreeting\'s from Vigneshwaram")
print("Welcome to phoneBook\n")
while True:
print("Type EDIT to edit the contact number\n CREATE to create a new contact\n SEARCH to search a specific contact\n DELETE to Delete the contact\n VIEW to view all contacts in PhoneBook")
print('')
function = input("Enter the function: ").lower()
def view():
print('')
print("Here is your phoneBook :- ")
print(database)
print('')
def create():
print('')
name = input("Enter the name of the contact: ")
number = int(input("Enter the number of the contact: "))
print('')
database.setdefault(name,number)
print("Contact updated succesfully")
print('')
print(database)
print('')
def delete():
print('')
print(database)
print('')
delete = input("Enter contact to delete: ")
print('')
if delete in database:
database.pop(delete)
print(database)
print('')
print("Contact succesfully deleted !!")
print('')
else:
print("Given contact doesn\'t exist in phoneBook !!")
print('')
def search():
print('')
search = input("Enter contact to search: ")
print('')
if search in database:
print(database[search])
print('')
if search not in database:
print('')
print("Contact doesn't exist in Phonebook !!")
print('')
print("Do you want to create that contact?")
print('')
function1 = input("CREATE to create or EXIT to ignore: ").lower()
if function1 == "create":
print('')
create()
elif function1 == "exit":
print('')
pass
else:
print('')
print("Invalid input from user contact admin(Vignesh)")
print('')
def edit():
print('')
print(database)
print('')
edit = input("Enter the contact which you want to edit: ")
print('')
if edit in database:
editNumber = int(input("Enter the new number: "))
database[edit] = editNumber
print('')
print("Contact updated succesfully")
print('')
print(database)
print('')
else:
print("Given contact doesn't exist in Phonebook")
print('')
sys.exit()
if function == "edit":
edit()
elif function == "create":
create()
elif function == "search":
search()
elif function == "delete":
delete()
elif function == "view":
view()
else:
print('')
print("Invalid user input contact admin(Vignesh)\n")
responce = input("Type \'RUN\' to keep your phoneBook open or \'EXIT\' to close your phoneBook: ").lower()
print('')
if responce == 'run':
print('')
print("Welcome back!!")
continue
elif responce == 'exit':
print('')
print('Hope you had a nice time !!')
break
else:
print('')
print(' Program has been discontinued due to Invalid input from user\n To continue run the file or contact Vignesh ')
print('')
break