[Tutor] Ammendment to the freezing program problem
Guess Who? Me
beercanz@hotmail.com
Sat Jan 11 19:45:02 2003
I just amended a few things, and revised the code, but now instead of
freezing it just returns a 0 - I figured out it freezes if I unindent the
'return total) line. I know its returning a 0 because I've given 'total=0',
but I'm stumpted (so far) as to how to make this thing return a value that
adds the values of the random numbers.
New (still no good) source
*********
#Make use of a random number integer function to make a dice roll program
import random
print "Welcome to my dice roll program."
value=0
rolls=input("How many rolls would you like to make?")
sides=input("How many sides does your dice have?")
def dice(number,sides): #number being the number of times you roll
total=0 ## < - Think the problem's here but I don't know what to do
while number > -1 :
value==random.randint(0,sides)
total=value+total
number=number+1
return total
print dice(rolls,sides)
**************************
Thanks, and sorry for that last Email, I should have re-read my source
another time.
Travis
_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus