Skip to content

Commit

Permalink
Thinkful-Logic Drills: Traffic light - python
Browse files Browse the repository at this point in the history
  • Loading branch information
siobhan-doherty committed Nov 24, 2023
1 parent efc9b8e commit 185c3a9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Python/8kyu/update_light.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# https://www.codewars.com/kata/58649884a1659ed6cb000072
# 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.

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

0 comments on commit 185c3a9

Please sign in to comment.