[Tutor] Help regarding lists, dictionaries and tuples (bob gailer)
Robert Sjöblom
robert.sjoblom at gmail.com
Wed Nov 24 03:22:35 CET 2010
On Mon, Nov 22, 2010 at 10:27 AM, <tutor-request at python.org> wrote:
> Send Tutor mailing list submissions to
> tutor at python.org
>
[snip]
>> Ok, I'm clearly thinking in circles here. I used the interpreter to
>> figure out that both are fine but the first example has integers,
>> whereas the second has strings. Good to know. What I'm wondering then,
>> instead, is whether there's a good way to sum up the value of integral
>> data in a dictionary?
>
> Why would you want to sum them? You start with 30 points in the pool,
> then allocate them to the attributes. The sum will still be 30.
> Bob Gailer
Because the user should be able to spend 30 points, or remove points
from an attribute and get them back in the pool. Like so:
attributes { "Strength" : 0, "Health" : 0, "Wisdom" : 0, "Dexterity" : 0)
points = 30 - sum(attributes.values())
Or is there a better way to achieve the same result?
best regards,
Robert S.
More information about the Tutor
mailing list