Skip to content
Sign upLog in
← Back to Community

How to fix "Potential infinite loop" in Python

Profile icon
CalsonLee

When I run one of my Python programs, it throws the following error:

ExternalError: RangeError: Potential infinite loop. You can disable this from settings. on line 40

Does anyone know where the option to disable this is?

Answered by jackou [earned 5 cycles]
View Answer
Voters
Profile icon
ElliotBrantley
Profile icon
jackou
Profile icon
CalsonLee
Comments
hotnewtop
Profile icon
jackou

Could you link the the program please?

Profile icon
CalsonLee

https://repl.it/@CalsonLee/graphing-polynomials

@JacksonPhilips

Profile icon
jackou

@CalsonLee

This worked for me:

boi.ht() boi.up()

boi.setpos(-150,-150)

boi.down() for x in range(150): boi.setpos(getY(-150))
Profile icon
jackou

@JacksonPhilips
I think it's because when boi.setpos(x, getY(x)), that triggers x forever

Profile icon
CalsonLee

@JacksonPhilips
I assume what you mean by the code is that you replaced it in the original. It does get rid of the error, but it doesn't accomplish what the code was supposed to do. The error message states that warnings for "potential infinite loop" can be disabled, and so does the post for the implementation fo the safeguard. Do you have any idea where to find it?

Profile icon
CalsonLee

@JacksonPhilips
nevermind, I found the error. I think what happened was that setpos() is considered a loop, and my program was using a y coordinate of something like (-150)^3, which obviously would take forever for the turtle to get to, especially because I had not increased the turtle's speed. Thanks.