Guest User

Untitled

a guest
Jun 25th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. def diplay_Code(word):
  2. result_char = char(word)
  3. print(f'Character in Morse Code: {result_char} ')
  4.  
  5. for i in word:
  6. print('Number in Morse code:', number(i))
  7.  
  8.  
  9. def get_string():
  10. return input('String to morse: ')
  11.  
  12.  
  13. def char(word):
  14. if word == ' ':
  15. return 'space'
  16. elif word == ',':
  17. return '--..--'
  18. elif word == '.':
  19. return '.-.-.-'
  20. elif word == '?':
  21. return '..--..'
  22.  
  23.  
  24. def number(word):
  25. return ['-----', '.----', '..---', '...--', '....-', '.....', '-....', '--...', '---..', '----.'][int(word)]
  26.  
  27.  
  28. diplay_Code(get_string())
Add Comment
Please, Sign In to add comment