Ask coding questions

← Back to all posts
GarretThyCarrot (30)

How to make code forever in python and the stop when user says


Answered by Bookie0 (4575) [earned 5 cycles]
View Answer
Bookie0 (4575)

Well you can do a while True loop so that it loops forever, then do use an if statement to determine when the user says to stop, and then use break

Happy coding and hope this helps! =)

GarretThyCarrot (30)

@Bookie0 oh ok and then how with the if?

Bookie0 (4575)

just do

while True:
  # code here to be run forever
  stop = input("press 1 to stop")
  if stop == "1":


GarretThyCarrot (30)

Ok thank you so much for replying! Your ver fast @Bookie0

Bookie0 (4575)

sure (i'm fast bc im a lot on ask section ;) @GarretThyCarrot