首页 > 其他分享 > Thinkful - Logic Drills: Traffic light

Thinkful - Logic Drills: Traffic light

时间:2023-03-16 13:12:23浏览次数:36  
标签:light Drills green yellow current Traffic Thinkful red

DESCRIPTION
You're writing code to control your town's traffic lights. You need a function to handle each change from green, to yellow, to red, and then to green again.

Complete the function that takes a string as an argument representing the current state of the light and returns a string representing the state the light should change to.

For example, when the input is green, output should be yellow.
Solution

def update_light(current):
    return {"green": "yellow", "yellow": "red", "red": "green"}[current]

标签:light,Drills,green,yellow,current,Traffic,Thinkful,red
From: https://www.cnblogs.com/artwalker/p/17222174.html

相关文章