How do I get a python program to rerun itself -
this question has answer here:
- how re-run code in python? 5 answers
i want code below automatically rerun ideas hwo this? btw new stack overflow , python if doing wrong on either please let me know, thanks
import sys import os import random answer_correct_message = random.choice(['well done', 'correct answer','nice one','thats correct!']) answer_wrong_message = random.choice(['unlucky','thats wrong','nope']) random_num_1 = random.randint(1,10) random_num_2 = random.randint(1,10) def question_asker_and_answerer(): q2 = input("what " + str(random_num_1) + " + " + str(random_num_2) + "?") if q2 == random_num_1 + random_num_2: the_questions = true if the_questions == true: return (answer_correct_message) else: return (answer_wrong_message) else: the_questions = false if the_questions == true: return (answer_correct_message) else: print(answer_wrong_message) print question_asker_and_answerer()
this not situation need program rerun itself. sort of requirement when want script run daemon. matter of creating loop
while true: print question_asker_and_answerer()
Comments
Post a Comment