friends_list = []
print("欢迎使用好友管理系统")
print("1:添加好友")
print("2:删除好友")
print("3:备注好友")
print("4:展示好友")
print("5:退出")

while True:
    choice = int(input("请输入您的选择:"))
    if choice == 1:
        friend = input("请输入要添加好友姓名")
        friends_list.append(friend)
        print("添加成功!")
    elif choice == 2:
        friend = input("请输入要删除好友姓名")
        friends_list.remove(friend)
        print("删除成功!")
    elif choice == 3:
        old_name = input("请输入要修改的好友姓名")
        index = friends_list.index(old_name)
        new_name = input("请输入备注名")
        friends_list[index] = new_name
        print('备注成功')
    elif choice == 4:
        print(f'我的好友列表是:{sorted(friends_list)}')
    elif choice == 5:
        break
print("程序结束!")
Logo

快速构建 Web 应用程序

更多推荐