File tree Expand file tree Collapse file tree 1 file changed +71
-0
lines changed Expand file tree Collapse file tree 1 file changed +71
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ addressbook = {}
3
+
4
+ print ("Welcome to the Address-Book!" )
5
+ while True :
6
+ # Stampo il menù che viene ristampato ogni volta che un operazione finisce
7
+ s = input (
8
+ "1. Print Address Book"
9
+ "\n 2. Search"
10
+ "\n 3. Add"
11
+ "\n 4. Edit"
12
+ "\n 5. Delete"
13
+ "\n 6. Exit"
14
+ "\n Insert command: " )
15
+
16
+ if s == "1" :
17
+ print (addressbook )
18
+
19
+ elif s == "2" :
20
+ n = input ("Who are you looking for?: " )
21
+ if n in addressbook :
22
+ print (addressbook [n ])
23
+ else :
24
+ print ("Name not found!" )
25
+
26
+
27
+ elif s == "3" :
28
+ code = input ("Insert Nickname: " )
29
+ code = code .title ()
30
+
31
+ if code in addressbook :
32
+ print ("Contact is already present!!!" )
33
+ else :
34
+ name = input ("Insert name for " + code + " : " )
35
+ name = name .title ()
36
+ number = input ("Insert telephone-number for " + code + ": " )
37
+ addressbook [code ] = ['Name: ' + name , 'Number: ' + number ]
38
+
39
+
40
+
41
+ elif s == "4" :
42
+
43
+ code = input ("Insert Nickname to edit: " )
44
+ code = code .title ()
45
+ if code in addressbook :
46
+ print ("Contact found!" )
47
+ name1 = input ("Insert new name: " )
48
+ name1 = name1 .title ()
49
+ number1 = input ("Insert new number: " )
50
+ addressbook [code ] = "Name : " + name1 , " Number: " + number1
51
+ print (code + " is update!" )
52
+ else :
53
+ print ("Contact not present!!!" )
54
+
55
+
56
+ elif s == "5" :
57
+ name = input ("Insert Nickname to delete: " )
58
+ name = name .title ()
59
+ if name in addressbook :
60
+ addressbook .pop (name )
61
+ print ("Contact " + name + " is delete!" )
62
+ else :
63
+ print ("Contact not present!!!" )
64
+
65
+ elif s == "6" :
66
+ print ("Goodbye!!!" )
67
+ quit ()
68
+
69
+
70
+ else :
71
+ print ("Insert a valid choice!" )
You can’t perform that action at this time.
0 commit comments