|
| 1 | + |
| 2 | +addressbook= {} |
| 3 | + |
| 4 | +print("Welcome to the Address-Book!") |
| 5 | +whileTrue: |
| 6 | +# Stampo il menù che viene ristampato ogni volta che un operazione finisce |
| 7 | +s=input( |
| 8 | +"1. Print Address Book" |
| 9 | +"\n2. Search" |
| 10 | +"\n3. Add" |
| 11 | +"\n4. Edit" |
| 12 | +"\n5. Delete" |
| 13 | +"\n6. Exit" |
| 14 | +"\nInsert command: ") |
| 15 | + |
| 16 | +ifs=="1": |
| 17 | +print(addressbook) |
| 18 | + |
| 19 | +elifs=="2": |
| 20 | +n=input("Who are you looking for?: ") |
| 21 | +ifninaddressbook: |
| 22 | +print(addressbook[n]) |
| 23 | +else: |
| 24 | +print("Name not found!") |
| 25 | + |
| 26 | + |
| 27 | +elifs=="3": |
| 28 | +code=input("Insert Nickname: ") |
| 29 | +code=code.title() |
| 30 | + |
| 31 | +ifcodeinaddressbook: |
| 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 | +elifs=="4": |
| 42 | + |
| 43 | +code=input("Insert Nickname to edit: ") |
| 44 | +code=code.title() |
| 45 | +ifcodeinaddressbook: |
| 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 | +elifs=="5": |
| 57 | +name=input("Insert Nickname to delete: ") |
| 58 | +name=name.title() |
| 59 | +ifnameinaddressbook: |
| 60 | +addressbook.pop(name) |
| 61 | +print("Contact "+name+" is delete!") |
| 62 | +else: |
| 63 | +print("Contact not present!!!") |
| 64 | + |
| 65 | +elifs=="6": |
| 66 | +print("Goodbye!!!") |
| 67 | +quit() |
| 68 | + |
| 69 | + |
| 70 | +else: |
| 71 | +print("Insert a valid choice!") |