Python .lower在pycharm中不适用于我的代码

Python .lower在pycharm中不适用于我的代码,python,lowercase,Python,Lowercase,我是python新手,下面是我的代码和代码。lower通常可以工作,但这次不行 technical_dict = { dict : 'stores a key/value pair', list : 'stores a value at each index', map : 'see dict', set : 'stores unordered unique elements' } userInput = (inp

我是python新手,下面是我的代码和代码。lower通常可以工作,但这次不行

technical_dict = {
        dict : 'stores a key/value pair',
        list : 'stores a value at each index',
        map : 'see dict',
        set : 'stores unordered unique elements'
    }

    userInput = (input("What term would you like to lookup or type 'exit' to stop:"))
    if userInput.lower() not in technical_dict:
        print("Term does not exist in technical dictionary")
    if userInput.lower()  in technical_dict:
        print(technical_dict[userInput.lower()])
        while userInput.lower() != "exit":
            userInput = input("What term would you like to lookup or type 'exit' to stop:")
            if userInput.lower() in technical_dict:
        print(technical_dict[userInput.lower()])
            if userInput.lower() not in technical_dict:
                print("Term does not exist in technical dictionary")
                break

您如何创建词典似乎有问题。您现在拥有的键值不是string或str类型。这就是为什么您会得到dict没有“lower”属性的错误。要修复它,您需要更改值,使其为string类型。试试这个:

technical_dict = {
        'dict' : 'stores a key/value pair',
        'list' : 'stores a value at each index',
        'map' : 'see dict',
        'set' : 'stores unordered unique elements'
    }

您收到的错误是什么?是您的密钥类型吗?这是我得到的错误-AttributeError:type对象“dict”没有属性“lower”,请显示完整的错误回溯!你的
技术指令中的键不是故意串的吗?此外,我猜uou希望通过
technical_dict.keys()
检查输入,而不仅仅是
technical_dict