Python stops unexpectedly after 1 minute

Question:

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:

  • I’m using a Chromebook, specifically a school computer.
  • I’m running the program in Python 3, in Trinket.

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

Answers:

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.

Answered By: sappho7124

Thanks for everyone’s help!

First of all, I was wrong about the program ending with "60…" instead of "59…". I ran an old version of the code, and changed it while i posted the question….

Secondly, many of you were probably right about the fact that Trinket has a default timer of 1 minute. So that’s solved, thank you all!

I’m going to try and look for an alternative way to run Python other than Trinket, as my project requires multiple minutes of interaction to function correctly.

If anyone has any suggestions I’d be happy to recieve them, but for now I’ll be searching on my own. I’ll post another question if I need help