Ask coding questions

← Back to all posts
How to fix "Potential infinite loop" in Python
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
ElliotBrantley
jackou
CalsonLee
Comments
hotnewtop
jackou

Could you link the the program please?

CalsonLee
jackou

@CalsonLee
This worked for me:

boi.setpos(-150,-150)

jackou

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

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?

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.