How to make a program automatically after done?

I have a program which runs one function how do I make it run over and over again?

Hey @temimam

It depends on what language you’re using but I would recommend a for loop or a setInterval function.

setInterval({
  console.log('hello') // the code you want to run
}, 100) // the amount of milliseconds between each run

If you want the function to run infinitely, then I would use setInterval. Otherwise, a for loop is the way to go.

What programming language? And why should the function run over and over again? So many factors in determine which approach to use.

if you want to run your script at intervals, some kind of scheduler like cron can do the job for you

but the answer is really it depends, i don’t think there is one absolute correct answer to this question

1 Like

I’m using python
my program is a Caesar cipher which takes two inputs from the user message and shift key. then it inputs an encrypted message
I want the program to ask for input again right after it outputs the message.

I’m using python
my program is a Caesar cipher which takes two inputs from the user message and shift key. then it inputs an encrypted message
I want the program to ask for input again right after it outputs the message.

then i would just use a infinity while loop, raw_input or input (depending on your python version) will “pause” the program.