On 07/12/10 22:10, Al Stern wrote:
Tried to use the documentation but still getting the errors...
The 1st one has to do with the available_points
# set variables
attributes = {"strength": 0, "health": 0, "wisdom": 0, "dexterity": 0}
MAX_POINTS = 30
available_points = MAX_POINTS - attributes.values()
keys = attributes.keys()
values = attributes.values()
this is the error i'm getting...
Traceback (most recent call last):
File "C:\Users\Public\Documents\My Python
programs\role_playing_game1.py", line 8, in <module>
available_points = MAX_POINTS - attributes.values()
TypeError: unsupported operand type(s) for -: 'int' and 'dict_values'
I know using attributes.values here isn't correct but I can't figure
out how to put the sum of the values into that equation.
Using attributes.values is fine. There is a built in function for
summing all the values in a sequence, it's called "sum".
HTH
Adam.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor