Advertisement
cybereq

Morse

Nov 29th, 2022 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | Source Code | 0 0
  1. w = input().lower()
  2. dictA = { "0":"-----",
  3.         "1":".----",
  4.         "2":"..---",
  5.         "3":"...--",
  6.         "4":"....-",
  7.         "5":".....",
  8.         "6":"-....",
  9.         "7":"--...",
  10.         "8":"---..",
  11.         "9":"----.",
  12.         " ":" ",
  13.         "(":"-.--.-",
  14.         ")":"-.--.-",
  15.         ",":"--..--",
  16.         "-":"-....-",
  17.         ".":".-.-.-",
  18.         "/":"-..-.",
  19.         ":":"---...",
  20.         "=":"-...-",
  21.         "?":"..--..",
  22.         "@":".--.-.",
  23.         "a":".-",
  24.         "b":"-...",
  25.         "c":"-.-.",
  26.         "d":"-..",
  27.         "e":".",
  28.         "f":"..-.",
  29.         "g":"--.",
  30.         "h":"....",
  31.         "i":"..",
  32.         "j":".---",
  33.         "k":"-.-",
  34.         "l":".-..",
  35.         "m":"--",
  36.         "n":"-.",
  37.         "o":"---",
  38.         "p":".--.",
  39.         "q":"--.-",
  40.         "r":".-.",
  41.         "s":"...",
  42.         "t":"-",
  43.         "u":"..-",
  44.         "v":"...-",
  45.         "w":".--",
  46.         "x":"-..-",
  47.         "y":"-.--",
  48.         "z":"--.."}
  49.  
  50. morse = list(map(lambda x: dictA.get(x," "),w))
  51. print(f"Tłumaczony tekst:\n {w}")
  52. print("Przełumaczony tekst:")
  53. print(" ".join(morse))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement