+ 1

Can anyone give me the logic on how to loop a program?

I made a program that simulates a speed gun radar, i used if statements because im not in the part of used case yet, if python has it. now i want to loop my program from the top as long as the user keeps pressing 'Y' from an input..the program is in my code play ground, not sure how to link it here.

26th Jul 2016, 12:17 AM
joel bonita
joel bonita - avatar
4 Answers
+ 5
while True: user_input = input("please enter Y to continue: ") if user_input == 'Y' or 'y': #paste your program here else: break This will create an endless loop until the user enters a character other than Y or y.
26th Jul 2016, 11:02 AM
Vladimir K. Bobyr
Vladimir K. Bobyr - avatar
+ 2
while does the check by itself. IF isn't required. user_input=char(input("Enter 'Y' to continue: ") while user_input== 'Y' or 'y': #your code
29th Jul 2016, 5:44 AM
Santhosh Dhaipule Chandrakanth
Santhosh Dhaipule Chandrakanth - avatar
0
you need use multiprocessing import multiprocessing def check_input(event): if input("yes or no") not in ['y', 'yes']: event.set() event=multiprocessing.Event() process = multiprocessing.Process(target=check_input, arts=(event,)) process.start() process.join()
26th Jul 2016, 6:49 AM
Sweemyn
0
@sweemyn hmmm not in that part yet, i am new at programming and python is the first language i chose though i think i can somehow manage to implement that to the one i made i can get the gist of your example, more or less. Thanks by the way :)
26th Jul 2016, 9:21 AM
joel bonita
joel bonita - avatar