Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- response = 1
- contacts = []
- while response != 0:
- response = int(input("Enter:\n1. to add\n2. to remove\n3. to print\n0. to exit\n"))
- if response == 1:
- name = input("Enter the name you want to add: ")
- if name in contacts:
- print("Name already present in contacts")
- else:
- contacts.append(name)
- print("Name added successfully")
- elif response == 2:
- name = input("Enter the name you want to remove: ")
- if name not in contacts:
- print("Name not present in contacts")
- else:
- contacts.remove(name)
- print("Name removed successfully")
- elif response == 3:
- contacts.sort()
- for name in contacts:
- print(name)
- print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement