[Tutor] Maths operations on lists

valhalla tireseas@onetel.com
Tue Jun 10 16:00:03 2003


Hello Pythonites

This may be a no-brainer, but after looking at several docs on lists I ca=
nnot=20
get my head around the proper way of doing this, so I would appreciate so=
me=20
help.

I'm working on a pretty basic guessing game, but wanted to keep a tally o=
f the=20
number of times it takes the player to guess the correct number and then =
to=20
average that tally out over the number of games, to yield an output along=
 the=20
lines of: "You took an average of 5 guesses", or whatever.
The inputs would be:
(a) the number of guesses per game which I have appended to a list
(b) the total number of games played
and the output
(a) divided by (b) =3D=3D (c) average

I *think* what I am after is a way of adding the contents of a list and t=
hen=20
dividing that total to yield an average - but I'm not sure (i) whether on=
e=20
can do those operations with lists and if so, how or (ii) if not, what th=
e=20
next best thing would be, given that there has to be a data structure to=20
catch the number of guesses per game.=20

Any ideas/clues?

Cheers
=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
||  Reg. Linux User: 313143 ||
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Sign the Petition:
http://www.PetitionOnline.com/endtcpa1/