pythontimeoutsleepremote-debuggingremote-server

Python stops unexpectedly after 1 minute


My Python program stops functioning after exactly 1 minute. Regardless of the code's size, the program stops after exactly 1 minute.

Here is some very simple code:

import time

seconds = 60

print(f"Trying to print 'Hello'. Wait {seconds} seconds.")

for second in range(1,seconds):
  time.sleep(1)
  print(f"{second}...")

print("Hello")

It first says it is going to print "Hello" in 60 seconds. In the approaching for-loop, the program counts upwards until it reaches 60 seconds. Finally, In the program should print "Hello". In theory.

But when I run the code, the last line printed is "60...", and then the program stops unexpectedly.

Here are some factors which I think could be important to figuring this out:

What could cause this problem and how can I solve it?


Solution

  • Maybe is timing you out of trinket or there is a problem in your network because this is the output is giving me result from trinket If anything the only thing i see wrong is the fact that it ends in 59 and not in 60, this is because in python for loops stop 1 integer before the given value, ej: range(6) is not the values of 0 to 6, but the values 0 to 5.