Q:

descriptor 'values' requires a 'dict' object but received a 'int'/'str' python

if 0 in dict.values(feedbackdict["%s" %log]):
    print ("Sorry, you have either not been left feedback for your spelling tesy yet or have not yet completed your spelling test. \nYou will be returned to the main menu.")
    LoggedInStudent(log)
else:
    feedback = dict.values(feedbackdict["%s" %log])
    print (feedback)

So what I am trying to do is make sure that if the user has recieved no feedback (which means that the value of the key would be '0', that the program will recognise this and return the user to the main menu. However, if the feedback is not '0' then the program should recognise that there is a string there and define it as 'feedback' and then display it to show the user their feedback.
I am trying to define 'feedback' as the value of a certain key (in this case the key is %log, which could be a user's name, for example 'matt') but when I try to execute this, I recieve the error:
TypeError: descriptor 'values' requires a 'dict' object but received a 'int'

I am confused as to why this is not working. Shouldn't 'feedback' simply be defined as the value which links to the key? For example, in my dictionary, the key 'Matt1' has the value 'Good job!', but when the program tries to gather this it gives me the error:
TypeError: descriptor 'values' requires a 'dict' object but received a 'str'

I am confused as to why the program is requiring a dict object. Is there any way to solve this? Sorry if the explanation is a bit sub-par. 

A:

That's simple. From what I noticed, I think you're using your dictionary object a bit in the wrong way. To clarify...
If your dict variable is named feedbackdict, Why would you access it's values as dict.values(feedbackdict[key]) when you should simply access it as feedbackdict[key].
You're getting the TypeError exception because dict.values is an unbound method of the dict class and takes a dict instance as it's only argument (your passed it an int once and a str the other)
Try something like this instead..
feedback = feedbackdict["%s" % log]
if feedback == 0:
    print("Sorry, you have either not been left feedback for your spelling test yet or have not yet completed your spelling test. \nYou will be returned to the main menu.")
    LoggedInStudent(log)
else:
    print(feedback)

Hope this helps

