light_color = input("What is the color of the traffic light? (red, yellow, or green) ").lower()
if light_color == 'red':
action = "Stop"
elif light_color == 'yellow':
action = "Slow down and prepare to stop"
elif light_color == 'green':
action = "Go ahead"
else:
action = "Invalid color - please enter red, yellow, or green."
print(f"The light is {light_color}. You should: {action}")
light_color = input("What is the color of the traffic light? (red, yellow, or green) ").lower()
if light_color == 'red':
action = "Stop"
elif light_color == 'yellow':
action = "Slow down and prepare to stop"
elif light_color == 'green':
action = "Go ahead"
else:
action = "Invalid color - please enter red, yellow, or green."
print(f"The light is {light_color}. You should: {action}")
print("Welcome to the Python Vending Machine! Here are your choices:")
print("1: Chips")
print("2: Chocolate")
print("3: Soda")
print("4: Candy")
choice = input("Please enter the number of your choice: ")
if choice == '1':
result = "You have selected Chips. Dispensing..."
elif choice == '2':
result = "You have selected Chocolate. Dispensing..."
elif choice == '3':
result = "You have selected Soda. Dispensing..."
elif choice == '4':
result = "You have selected Candy. Dispensing..."
else:
result = "Invalid selection. Please choose a number between 1 and 4."
print(result)