나는 이렇게 학습한다/Algorithm & SQL
0830. Switch it Up!
daco2020
2022. 8. 30. 22:47
When provided with a number between 0-9, return it in words.
Input :: 1
Output :: "One".
Solution:
def as_word(func):
def wrapper(number, *args):
ko_word = ["영", "일", "이", "삼", "사", "오", "육", "칠", "팔", "구"][number]
en_word = ["Zero","One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"][number]
return func(ko_word, en_word, *args)
return wrapper
@as_word
def switch_it_up(ko_word: str, en_word: str, language: str = "en") -> str:
switch = dict(en=en_word, ko=ko_word)
return switch[language]