PROBLEM 65
Medium

Traffic Light

Programming Basics · Python

</>
STATUS Not solved

TASK

Problem

#65

Given traffic-light color `red`, `yellow`, or `green`, print `STOP`, `WAIT`, or `GO`.

EXAMPLE

Example

Input
green
Output
GO

LIMITS

Constraints

color ∈ {red, yellow, green}
📖
LEARN Theory for this problem
+

`input()` reads data entered by the user. The result of `input()` is initially a string. Comparison operators `==`, `!=`, `<`, `>`, `<=`, `>=` compare values and produce `True` or `False`. `if` checks a condition and runs its block when the condition is true. `else` runs when the corresponding `if` condition is false. `print()` displays the program result. Print only what the problem statement requires.

**Connection to this task.** An `if` statement chooses a program branch from a Boolean condition. Comparisons produce `True` or `False`, and `elif` lets you test several mutually exclusive cases in order. The expression `'STOP'` shows how this idea is applied to the task data.

💡
NEED HELP? Hints
+

['Compare the string with each valid color.']

ANSWER Solution
+
c = input()
if c == 'red':
    print('STOP')
elif c == 'yellow':
    print('WAIT')
else:
    print('GO')