forked from fenyx-it-academy/Class5-Python-Module-Week2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContact_List.py
More file actions
49 lines (47 loc) · 1.88 KB
/
Contact_List.py
File metadata and controls
49 lines (47 loc) · 1.88 KB
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
contact = {}
importantcontact = {}
selection = input("select : add ,edit, delete")
while True:
if selection == "add":
while True:
name = input("name:")
if name.isalpha() == False:
print("invalid entry! please try again")
else:
break
while True:
number = input("number:")
if number.isnumeric()==False or len(number) != 10:
print("invalid entry! please try again")
else:
break
important=input("do you want to add important list:y/n")
if important == "y":
importantcontact.update({name :number})
contact.update({name :number})
elif important=="n":
contact.update({name :number})
print("Registration Successful")
if selection == "edit":
name=input("write the name of person to edit:")
while True:
number2 = input("write the second number of person to edit")
if number2.isnumeric()==False or len(number2) != 10:
print("invalid entry! please try again")
else:
break
important=input("do you want to add important list:y/n")
if important == "y":
importantcontact[name]=[number, number2]
contact[name]=[number, number2]
elif important=="n":
contact[name]=[number, number2]
print(number2,"added ",name,"succesfully!")
elif selection == "delete":
delname=input("delete name:")
contact.pop(delname)
importantcontact.pop(delname)
print(delname,"Has been succesfully deleted!")
impartantcontact = tuple(importantcontact.items())
print (contact)
print (impartantcontact)