Reputation: 21
I want my program to keep running even after I enter the first input. My program looks like this:
import os
import sys
print("Hello Officer. Let's get started!")
speed = int(input("Enter car's speed mph: "))
if 70<= speed <=75:
print("Warning: speeding camera in process!")
elif 76<= speed < 100:
print("Issue $50 Fine.")
elif speed >= 100:
print("Issue $100 Fine and pull car over!")
else:
print("No Action")
os.execl(sys.executable, '"{}"'.format(sys.executable), *sys.argv)
When I run the program, I get this:
================================ RESTART: Shell ================================
and the program doesn't actually restart. How do I make it work?
Upvotes: 0
Views: 72
Reputation: 297
You should wrap the whole program in a while true loop.
while True:
print("Hello Officer. Let's get started!")
speed = int(input("Enter car's speed mph: "))
if 70<= speed <=75:
print("Warning: speeding camera in process!")
elif 76<= speed < 100:
print("Issue $50 Fine.")
elif speed >= 100:
print("Issue $100 Fine and pull car over!")
else:
print("No Action")
Upvotes: 1