solutions

Traffic light

Define a function traffic_light that receives a color and returns:

'stop' if the color is red

'slow down' if the color is yellow

'go' if the color is green

Examples:

>>> traffic_light('red')
'stop'
>>> traffic_light('yellow')
'slow down'
>>> traffic_light('green')
'go'

Test Cases

test green light - Run Test

def test_green_light():
    assert traffic_light('green') == 'go'

test red light - Run Test

def test_red_light():
    assert traffic_light('red') == 'stop'

test yellow light - Run Test

def test_yellow_light():
    assert traffic_light('yellow') == 'slow down'