import random b=0 for i in range(300): a = random.random() if a>0.5: b=b+1 else: b=b-1 if b==39: print(b) break