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

我正在为一门名为编程入门的课程做一些功课。我正在制作一个带有字典列表的小型查找应用程序。我只是好奇我能做些什么来让用户可以输入例如“pubg”而不是“PUBG”?我到处都尝试过 .lower() 但因为我不太了解它是如何工作的,所以我不知道我需要改变什么。


import sys

while 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")


弑天下
浏览 166回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python