# 手機通訊錄管理系統
names =[]
phones = []
while True:
print("\t\t\t\t=====歡迎使用手機通訊錄管理系統=======")
print("\t\t\t\t1,添加姓名和手機号碼")
print('\t\t\t\t2,删除姓名和手機号碼')
print("\t\t\t\t3,根據姓名查找手機号碼")
print('\t\t\t\t4,修改手機号碼')
print("\t\t\t\t5,查詢所有聯系人")
print('\t\t\t\t6,退出系統')
print("\t\t\t\t=========================================")
i = int(input("請選擇你想進行的操作:"))
if i == 1:
name = input("\t請輸入要添加的姓名:")
phone = input("\t請輸入要添加的電話号碼:")
while phone in phones:
phone = input("\t号碼已經存在,請重新輸入:")
else:
names.append(name)
phones.append(phone)
print("添加成功!")
elif i == 2:
name = input("\t請輸入要删除的姓名:")
while name not in names:
name = input("\t姓名不存在,請重新輸入:")
index = names.index(name)
del names[index]
del phones[index]
print("删除成功!")
elif i == 3:
name = input("\t請輸入想要查找的姓名:")
print("\t\t{} 的電話号碼是 :{}".format(name,phones[index]))
elif i == 4:
phone = input("\t請輸入要修改的電話号碼:")
new_phone = input("\t請輸入新号碼:")
while new_phone in phones:
new_phone = input("\t該号碼已經存在,請重新輸入:")
index = phones.index(phone)
phones[index] = new_phone
print("修改成功!")
break
else:
phone = input("\t号碼不存在,請重新輸入:")
elif i == 5:
print("\t全部聯系人:")
for i in range(len(names)):
print("\t\t",names[i],phones[i])
print("\t輸出完畢!")
print("謝謝使用!")