Thanks for the advice.  I think I have the dictionary function set up right
now although I'm still not clear why it is better than the list.

attributes = {"strength": 0, "health": 0, "wisdom": 0, "dexterity": 0}

I think my next task is to set up a while function based on when
available_points drops below 0.  A little lost on how to do it though.

-----Original Message-----
From: tutor-bounces+alans=risingrealty....@python.org
[mailto:tutor-bounces+alans=risingrealty....@python.org] On Behalf Of Robert
Sjöblom
Sent: Monday, December 06, 2010 8:04 AM
To: tutor@python.org
Subject: Re: [Tutor] role playing game - help needed

>I am starting with a book called Python Programming for the Absolute
Beginner by Michael Dawson.  The book has been >pretty good >and up to this
point, I have grasped all the concepts it has covered.  At the end of each
chapter, there are a number of challenges you >need to complete before
moving on.  Problem is, I have gotten stumped on one in Chapter 5: Lists and
Dictionaries.
[snip]
> attributes = ["strength", "health", "wisdom", "dexterity"]
> points = [0,0,0,0]
> MAX_POINTS = 30
> available_points = MAX_POINTS - sum(points)

Before anyone comments that you can write a function for the points
system, which was helpful to me when I asked a question regarding that
very chapter: The book doesn't deal with functions until Chapter 6.

As for your problem, Alan; I believe Alan already answered it -- you
have two different lists, attributes and points, but a dictionary
would be easier to handle. Not to say that it couldn't be done the way
you're doing it though. A dictionary is built with key:value pairs.
Then it's just about figuring out a way to change the value associated
with each key when the attribute changes. I don't want to spoil the
challenge of working it out yourself, but when I asked I was told to
check out how values() and sum() worked.

best regards,
Robert S.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to