Answer the question
In order to leave comments, you need to log in
How to write functions to translate to Morse code without using lists, tuples, dictionaries?
How can I rewrite the code to not use lists, tuples, dictionaries to convert to Morse code?
MORSE_DICT = {'0': '-----', '1': '.----', '2': '..---', '3': '...--' ,
'4': '....-', '5': '.....', '6': '-....',
'7': '--...', ' 8': '---..', '9': '----.',
}
def morse_number(numbers):
result = ''
for number in numbers:
if number != ' ':
result += MORSE_DICT [number] + ' '
else:
result += ' '
return result
print(morse_number('005'))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question