[SOLVED] How do I convert my traffic signal python script into a bash script?
by Varister from LinuxQuestions.org on (#5QSWH)
I would like to convert the following code to bash:
Code:from random import randrange
Red = 1
Yellow = 2
Green = 3
def process_light(x):
if x == Red:
print("red light")
return Green
elif x == Yellow:
print("yellow light")
return Red
elif x == Green:
print("green light")
return Yellow
generatedLight = randrange(1, 4)
while True:
generatedLight = process_light(generatedLight)
Code:from random import randrange
Red = 1
Yellow = 2
Green = 3
def process_light(x):
if x == Red:
print("red light")
return Green
elif x == Yellow:
print("yellow light")
return Red
elif x == Green:
print("green light")
return Yellow
generatedLight = randrange(1, 4)
while True:
generatedLight = process_light(generatedLight)