Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python - check at the end of the loop if need to run again

Tags:

python

loops

It's a really basic question but i can't think at the second. How do i set up a loop that asks each time the function inside runs whether to do it again. So it runs it then says something like;

"loop again? y/n"

like image 570
user33061 Avatar asked Sep 16 '25 15:09

user33061


1 Answers

while True:
    func()
    answer = raw_input( "Loop again? " )
    if answer != 'y':
        break
like image 172
Martin Cote Avatar answered Sep 19 '25 07:09

Martin Cote