• Morse decoder

 
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', '-----': '0',
     '.----': '1', '..---': '2', '...--': '3',
     '....-': '4', '.....': '5', '-....': '6',
     '--...': '7', '---..': '8', '----.': '9'
    }

def morse_decoder(code):
if '   ' in code:
    words = [el.split(' ') for el in code.split('   ')]
    result = ''
    for word in words:
        result += ''.join([key for el in word for key, value in MORSE.items() if el == value]) + ' '
    result = result.rstrip()
    print(result, result[0], result[0].isalpha())
    if result[0].isalpha():
        result = result.replace(result[0], result[0].upper())
else:
    words = code.split(' ')
    result = ''.join([key for el in words for key, value in MORSE.items() if value == el])
return '"{}"'.format(result)

Hello! This line "result += ''.join([key for el in word for key, value in MORSE.items() if el == value]) + ' '" return an empty string(""), but in pycharm it's return not an empty string. What's wrong?

.