On 02/03/18 21:05, Roger Lea Scherer wrote:
> ability to exchange point between the pool and each of the, what I call,
> attributes of Strength, Health, Wisdom, and Dexterity. I got only to the
> first option and I'm stuck on how to get the points to change
> "permanently". The program will run well for option 1 (I haven't got to the
> rest of the options), but the next time I run the program it goes back to
> the original configuration. Did I do everything right, but I just need to
> write to a file, and that's what the problem is? or what?

You are correct on all counts.
Every time you run the program it is reinitialised
to the hard coded values.

To make the changes stick you would need to store
them somewhere and then read them at startup.
There are many ways to do that, some work better
than others with dictionaries: the shelve module
or the CSV module or the JSON module are all fairly
easy to use.

However, I suspect the book's author is only looking
for you to play the game once and then forget the
values (or start afresh) She/he will likely cover
files later.

To that end you need to look at wrapping your menu
selection in a loop (probably a while) and keep on
applying the changes until you are done.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:

Reply via email to