<div>Ok. I think I am starting to get it but still not sure how to separate the value from the key. Once I have this...</div>
<div> </div>
<div>attributes = {"strength": 0, "health": 0, "wisdom": 0, "dexterity": 0}<br>MAX_POINTS = 30</div>
<div> </div>
<div>How do I set the variable for available_points?</div>
<div> </div>
<div>available_points = MAX_POINTS - (not sure what goes here)</div>
<div> </div>
<div>I am pretty sure I will change the values by something like this...</div>
<div> </div>
<div>attributes["strength"] = input("\nHow many points do you want to assign to strength?: ")</div>
<div> </div>
<div>Please let me know if this isn't advisable. It seems to work on the surface.<br><br></div>
<div class="gmail_quote">On Mon, Dec 6, 2010 at 1:16 PM, Alan Gauld <span dir="ltr"><<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><br>"Al Stern" <<a href="mailto:albstern@gmail.com" target="_blank">albstern@gmail.com</a>> wrote
<div class="im"><br><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Thanks for the advice. I think I have the dictionary function set up right<br>now although I'm still not clear why it is better than the list.<br>
<br>attributes = {"strength": 0, "health": 0, "wisdom": 0, "dexterity": 0}<br></blockquote><br></div>Consider where you want to update the points for "health"<br><br>Using two lists you need to loop over the keys list to find the index<br>
of "health" then access the values list to set the points. Something<br>like this:<br><br>for x in range(len(keys)):<br> if keys[x] == "health":<br> values[x] = newValue<br><br>With a dictionary you just need to do<br>
<br>attributes["health"] = newValue<br><br>That's a lot less typing and will be faster performance too.<br>I'd also say its a lot easier to see whats happening - its more readable.<br><br>HTH,<br><font color="#888888"><br>
-- <br>Alan Gauld<br>Author of the Learn to Program web site<br><a href="http://www.alan-g.me.uk/" target="_blank">http://www.alan-g.me.uk/</a></font>
<div>
<div></div>
<div class="h5"><br><br><br><br>_______________________________________________<br>Tutor maillist - <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br></div></div></blockquote></div><br>