I have a function which returns either True or False. I'm trying to perform a loop where that function is called several times until it returns False, and count how many times it ran.
import random as rand
def test_function():
return rand.random > 0.5
count = 0
while test_function():
count += 1
print count
All this is doing is running it once though, and holding whatever value it got.
python -c "from random import randint as r; print r(0,1)"or evenprint "mean count: 0.5":-)