Hello Tutor list.
I'm running a test to find what the experimental average of a d20 is, and came across a strange bug in my code.
import random
list1 = []
def p():
   d = 0
   for number in range(1,1000):
       t = random.randrange(1,19)
       list1.append(t)
   for value in list1:
       d+=value
   print d/1000
   d = 0
for value in range(1,100):
   p()

It works, but I have a logic error somewhere. It runs, and the results have a pattern :
9
19
28
37
47
56
66
75
85
94
104
113
...
...
It just adds 10, and every second result, subtracts 1, till it gets to 0, and then starts again with 9 in singles, and whatever in the 10's, etc.
What is causing this?
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to