반응형
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]
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0901. Alan Partridge II - Apple Turnover (0) | 2022.09.01 |
---|---|
0831. Correct the mistakes of the character recognition software (0) | 2022.08.31 |
0829. Holiday VIII - Duty Free (0) | 2022.08.29 |
0828. Basic Mathematical Operations (0) | 2022.08.28 |
0827. Sum Arrays (0) | 2022.08.27 |