Traffic lights are signaling devices positioned at road intersections, pedestrian crossings, and other locations to control flows of traffic. Traffic lights alternate the right way accorded to users by displaying lights of a standard color (red, orange and green) following a universal color code.

verkeerlicht

In the typical sequence of color phases:

Assignment

Define a class TrafficLight that can be used to represent traffic lights in Python. At any point in time, each traffic light is in one of three possible states: red, orange or green. The class TrafficLight must support at least the following methods:

No arguments can be passed to the methods __str__, __repr__ and next.

Example

>>> light1 = TrafficLight()
>>> light1
TrafficLight('red')
>>> licht2 = TrafficLight('green')
>>> print(light1, light2)
red green
>>> light1.next()
>>> print(light1, light2)
green green
>>> light1.next()
>>> light1.next()
>>> light2.next()
>>> print(light1, light2)
red orange