This code is about a problem Matt Parker asked on his video Can you solve The Frog Problem?. It runs perfectly on Thonny's shell (3.7.9) but gives an error in Python IDLE Shell 3.9.4. Does anyone know why this happens and/or how to solve it please?
import random
def nextstesp(currstep, maxstep, stepsnum, stepslist):
#does 1 step if is not at the end, if it is it resets its position
while currstep!=maxstep:
currstep=random.randint(int(currstep)+1, maxstep)
stepsnum+=1
stepslist.append(stepsnum)
stepsnum=0
currstep=0
#initialises varibles and lists
currstep=0
maxstep=int(input('maxstep='))
stepsnum=0
stepslist=[]
#simulates the crossing many many times
for i in range(10000):
nextstesp(currstep, maxstep, stepsnum, stepslist)
#averages out the number of steps
average=sum(stepslist)/len(stepslist)
print(average)
Python IDLE Shell 3.9.4 screenshot Thonny's Shell 3.7.9 screenshot