为了账号安全,请及时绑定邮箱和手机立即绑定

“pubg”而不是“PUBG” - 区分大小写的输入问题

“pubg”而不是“PUBG” - 区分大小写的输入问题

弑天下 2021-09-11 15:21:17
我正在为一门名为编程入门的课程做一些功课。我正在制作一个带有字典列表的小型查找应用程序。我只是好奇我能做些什么来让用户可以输入例如“pubg”而不是“PUBG”?我到处都尝试过 .lower() 但因为我不太了解它是如何工作的,所以我不知道我需要改变什么。import syswhile True:    print("-" * 45)    print("\n" "Welcome to game creator lookup!")    game_list = {            "Battlefield" : "EA DICE",            "Fortnite" : "Epic Games",            "Counter strike" : "Valve",            "PUBG" : "PUBG Corporation",            "Overwatch" : "Blizzard",            "Dota" : "Valve",            "Call of duty" : "Infinity Ward",            "The sims" : "EA, Maxis, Firemoney studios"}    choice = (input("What game would you like to look up? (Type 'q' to quit) " "\n"))    if choice in game_list:        print (choice, "was created by", game_list[choice])    if choice == ("q"):        print("goodbye")        sys.exit()    elif choice not in game_list:        print("Invalid choice, try again")
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 144 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信