gsjdkdhh 2022-03-30 08:32 采纳率: 96.3%
浏览 33
已结题

关于#python#的问题,如何解决?

其中提示输入和输出结果的两句提示语请使用如下形式:
Please input the name:
Who has the nice number?

img

  • 写回答

1条回答 默认 最新

  • bekote 2022-03-30 09:39
    关注
    
    dic = {"xiaoyun": "88888", "xiaohong": "5555555", "xiaoteng": "11111", "xiaoyi": "1234321", "xiaoyang": "1212121"}
    name = input("Please input the name:\n")
    while name not in dic.keys():
        print("Enter the name again.")
        name = input("Please input the name:\n")
    print(dic[name])
    print("Who has the nice number?")
    names = []
    for name in dic.keys():
        if len(dic[name]) <= 5:
            names.append(name)
    names.sort()
    for name in names:
        print(name)
        
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月7日
  • 已采纳回答 3月30日
  • 创建了问题 3月30日