我正在为一门名为编程入门的课程做一些功课。我正在制作一个带有字典列表的小型查找应用程序。我只是好奇我能做些什么来让用户可以输入例如“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")
添加回答
举报
0/150
提交
取消