What you need is a while
loop since you don’t know how many times you need to go round.
(your for loop goes round a fixed number of times)
prob = 1
classsize = 1
while prob > 0.1:
prob = prob * (365 - classsize) / 365
classsize += 1
print(classsize)
output:
41
1
solved How do I prevent a variable from continuously adding in a loop in python?