+ 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.
4 ответов
+ 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.
+ 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
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()
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 :)