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'
Solution 1
def traffic_light(color):
if color == 'red':
return 'stop'
elif color == 'yellow':
return 'slow down'
elif color == 'green':
return 'go'