[Python] Python two-step solution[Python] Python two-step solution
☎️
Some Mars
Week 15, 2026
def main() -> None:
msg = "☀️ ❄️☀️☀️❄️ ☀️❄️ ❄️❄️ ☀️❄️❄️☀️ ☀️❄️☀️☀️ ☀️"
smsg = []
s = 0
el = ""
for c in msg:
if s == 3:
smsg.append(el)
el = c
s = 0
elif c != ' ':
el += c
s = 0
else:
s += 1
smsg.append(el)
result = ""
code_morse = {".-": 'a', "-...": 'b', "-.-.": 'c', "-..": 'd', ".": 'e',
"..-.": 'f', "--.": 'g', "....": 'h', "..": 'i', ".---": 'j',
"-.-": 'k', ".-..": 'l', "--": 'm', "-.": 'n', "---": 'o',
".--.": 'p', "--.-": 'q', ".-.": 'r', "...": 's', "-": 't',
"..-": 'u', "...-": 'v', ".--": 'w', "-..-": 'x', "-.--": 'y',
"--..": 'z', ".----": '1', "..---": '2', "...--": '3', "....-": '4',
".....": '5', "-....": '6', "--...": '7', "---..": '8', "----.": '9',
"-----": '0'}
for el in smsg:
if el != ' ':
result += code_morse[el.replace('❄️', '-').replace('☀️', '.')]
else:
result += ' '
print(result)
main()