Ask coding questions

← Back to all posts
How to keep my infinite loop python code alive forever on repl.
h
chethansai (0)

How to keep my infinite loop python code alive forever on repl. it restarts every one hour(I have hacker subscription)

Comments
hotnewtop
[deleted]

Um @chethansai u got some sketchy reply going on but I’ll mind my own biz

[deleted]

@tsunami21 u know python right well if u don’t oof for all

[deleted]

@tsunami21 help this person

[deleted]

Oh I give up

[deleted]

Just answer plz 🥺

[deleted]

Hello?

[deleted]

U gonna respond

[deleted]

There’s the answer

[deleted]

Search it up dude

[deleted]

Idk

TsunamiOrSumth (556)

@MemeDriod stop pinging me for useless stuff, i was busy

Coder100 (16915)

Actually it's the same, just that there usually is no real purpose for it

RYANTADIPARTHI (5999)

You could do it this way.

#!/usr/bin/python

import time

# some python code that I want 
# to keep on running


# Is this the right way to run the python program forever?
# And do I even need this time.sleep call?
while True:
    time.sleep(5)

or here are a few links:

https://stackoverflow.com/questions/20170251/how-to-run-the-python-program-forever
https://www.codegrepper.com/code-examples/python/infinite+loop+python