[Tutor] role playing game - help needed

Alan Gauld alan.gauld at btinternet.com
Mon Dec 6 09:36:47 CET 2010

"Alan Stern" <alans at risingrealty.com> wrote

> Hi all.  My name is Al Stern.

Hi Al,

> Chapter 5: Lists and Dictionaries.

Note Lists AND Dictionaries....

> I'm not sure exactly how this mailing list works but
> was hoping someone here could give me some insight

You are doing just fine.
The only extra info we could find helpful; are the Python version you 
and the OS you run.

For now, I'll assume Python v3 and Windows...

> I think I did ok setting up the variables but haven't figured out 
> where to go from there.
> Here is what I have (along with my latest error message).

I don;t see any error messages?
BTW. Please post complete error messages not just summaries.

Notice the topic. You have Lists but I see no dictionaries.
Think about how a dictionary works and how it could be useful here.

> attributes = ["strength", "health", "wisdom", "dexterity"]
> points = [0,0,0,0]

You ave a list of attributes and a separate list of points.
A dictionary holds a set of keys and associated values.
Can you see a connection?

available_points = MAX_POINTS - sum(points)

print ("You have", available_points, "points available to use.")

for x in range(len(attributes)):
  print ("\t",attributes[x], points[x])

for x in range(len(attributes)):
    point_choice = input("\n\nHow many points do you want to assign to 
" +  attributes[x]  + "?: ")

A start would be to convert the result to an integer and then assign 
to points[x]... Then modify available_points as needed.

However using a dictionary will simplify things considerably.


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list