Skip to content
C

Traffic Light Simulator (match-case)

Easypython

Read a traffic light color and print the correct action, using Python's match-case statement.

  • red -> Stop
  • yellow -> Get Ready
  • green -> Go
  • anything else -> Invalid signal

Approach: this is a direct application of match-case from this topic — one case per color, plus a case _: default for anything unrecognized.

Input: One line: a color name ("red", "yellow", or "green").

Output: One line: the matching action.

Input (stdin)

Output

Run your code to see output here...