# 练习:
# =======通讯录管理系统=======
# 1.增加姓名和手机
# 2.删除姓名
# 3.修改手机
# 4.查询所有用户
# 5.根据姓名查找手机号
# 6.退出
# ============================
print('='*6,'通讯录管理系统的','='*6)
print('''1.增加姓名和手机
2.删除姓名
3.修改手机
4.查询所有用户
5.根据姓名查找手机号
6.退出''')
print('='*29)
while True:
choose = input('Please enter the number above:')
if choose.isdigit():
name = ['lili']
phone = [12789456123]
if choose == '1':
while True:
user = input('Please enter your name:').lower()
if user in name:
print('Already exists,please re-enter!')
continue
else:
while True:
tel = input('Please enter your telephone:')
if len(tel) == 11:
tel = int(tel)
name.append(user)
phone.append(tel)
print(name)
print(phone)
break
else:
print('Invalid input!Please enter 11 digits!')
isexit = input("Are you sure you want to quit(y/n)?")
if isexit == 'y':
break
if choose == '2':
while True:
delname = input('Please enter the name you want to delete:').lower()
if delname in name:
nameindex = name.index(delname)
name.remove(delname)
phone.pop(nameindex)
# print(nameindex)
print(name)
print(phone)
break
else:
print('{} dosen\'t exist!Please re-enter your name!'.format(delname))
if choose == '3':
while True:
rephone = input('Please enter the phone you want to change:')
newphone = input('Please enter a new phone:')
if len(rephone) == 11 and len(newphone) == 11:
rephone = int(rephone)
newphone = int(newphone)
phoneindex = phone.index(rephone)
phone[phoneindex] = newphone
print(phone)
break
else:
print('Invalid input,please enter 11 digits!')
if choose == '4':
for i in name:
print(i)
if choose == '5':
while True:
check = input('Please enter the name of the phone number you look for:')
if check in name:
checkindex = name.index(check)
checktel = phone[checkindex]
print(checktel)
break
else:
print('Please enter existing contact!')
if choose == '6':
isexit = input('Are you sure you want to quit(y/s)?')
if isexit == 'y':
print('Thank you for landing!')
break
else:
print('Invalid input!')