Advertisement
robertvari

morse_help

Jan 20th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. morse={"a":".-",
  2.        "b":"-...",
  3.        "c":"-.-.",
  4.        "d":"-..",
  5.        "e":"."}
  6.  
  7. userInput = raw_input("Your text?")
  8.  
  9. result = []
  10. for i in userInput: # vegigmegyunk betunkent az userInputon
  11.  
  12.     if i.lower() in morse: # az osszehasonlitasnal kisbetuve alakitunk mindent
  13.  
  14.         result.append( morse[i.lower()] ) # appendoljuk a betu morse megfelelojet
  15.  
  16. print ''.join(result) # a join segitsegevel egy stringbe rakjuk a result listat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement