-3

I am new to python and here is my code and .lower usually works but this time it isn't.

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

1 Answers1

0

There seems to be a problem with how you are creating your dictionary. The key values that you have right now are not of type string, or str. This is why you are getting the error that a dict has no attribute 'lower'. To fix it you would change the values so that they are of type string. Try this:

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