Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #contactnumber
- import time
- import sys
- def start():
- names =[]
- phone_nums = []
- num = 1
- user = input("Enter your name: ")
- print(f"Hello {user}. Let's make a contact book! ")
- while True:
- name = input("Add a name: ")
- phone_num = input("Enter the phone number: ")
- names.append(name)
- phone_nums.append(phone_num)
- again = input("Add another? : (y/t)")
- if again == "y":
- print()
- num += 1
- continue
- else:
- print(f"\n---- {user}'s CONTACT BOOK ----")
- print("Name\t\t\tPhone Number")
- for i in range(num):
- print(f"{i+1}. {names[i]}\t\t\t{phone_nums[i]}")
- print()
- search = input("Enter name to search: ")
- time.sleep(0.7)
- if search in names:
- index = names.index(search)
- phone_num = phone_nums[index]
- print(20*'-')
- print("Result: ")
- print(f"Name: {search} | Phone Number: {phone_num}")
- print(20*"-")
- print("1 Add another contact\n2 Reset\n3 Exit")
- ask = input("Choose an option: ")
- if ask == "2" :
- start()
- elif ask == "1":
- num += 1
- continue
- else:
- print("BYE")
- sys.exit()
- else:
- print("Name not found..")
- print("1 Add another contact\n2 Reset\n3 Exit\n4 Try again ")
- ask = input("Choose an option: ")
- if ask == "2" :
- start()
- elif ask == "1":
- num += 1
- continue
- elif ask == "4":
- search = input("Enter name to search: ")
- time.sleep(0.7)
- if search in names:
- index = names.index(search)
- phone_num = phone_nums[index]
- print(20*'-')
- print("Result: ")
- print(f"Name: {search} | Phone Number: {phone_num}")
- print(20*"-")
- print("1 Add another contact\n2 Reset\n3 Exit")
- ask = input("Choose an option: ")
- if ask == "2" :
- start()
- elif ask == "1":
- num += 1
- continue
- else:
- print("BYE")
- sys.exit()
- else:
- print("BYE")
- sys.exit()
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement