how to make a morse code translator in python

import time

eng_to_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' : '--..', '.' : '.-.-.-', '?' : '..--..', ',' : '--..--', ' ' : '/'
}
outstr = ''
space = ' '
senc = 0
wordprocces = 0
word = input('Enter a sentance : ')
lenword = len(word)

for i in word:
    if i not in morse_to_eng:
        print('Data not formatted properly')
        time.sleep(5)
        break
    else:
        print(eng_to_morse[i], end=' ')

4
1
Phoenix Logan 186120 points

                                    import time
morse_to_eng = {
    '....' : 'h', '.-' : 'a', '-...' : 'b', '-.-.' : 'c', '-..' : 'd', '.' : 'e', '..-.' : 'f', '--.' : 'g', '..' : 'i', '.---' : 'j', '-.-' : 'k', '.-..' : 'l', '--' : 'm', '-.' : 'n', '---' : 'o', '.--.' : 'p', '--.-' : 'q', '.-.' : 'r', '...' : 's', '-' : 't', '..-' : 'u', '...-' : 'v', '.--' : 'w', '-..-' : 'x', '-.--' : 'y', '--..' : 'z', '.-.-.-' : '.', '..--..' : '?', '--..--' : ',', '/' : ' '
}

word = input('Enter a sentance : ')
lenword = len(word)
words = ''
for i in word:
    if i != ' ':
        words=words+i
        if i not in morse_to_eng:
            print('Data not formatted properly')
            time.sleep(5)
            break
    elif i == '/':
        print(morse_to_eng[words], end=' ')
    else:
        print(morse_to_eng[words], end='')
        words = ''

4 (1 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
morse code converter in python python translate text file to morse code morse code translator python api morse code generator python how to convert letters to morse code python python program text to morse code python morse code to english python interpret morse code python library to convert english morse code text to morse code python morse to words python morse code to text converter python morse translator python string to morse code python convert text to morse code in python python morse 'code how to write a python program for a morse code morse code translator . python morse code translator python module morse code converter python convert morse code python python morse code encoder convert string to morse code python python program translate morse morse code generator micro python english to morse code python code to convert morse code to text python morse code python program how to make a morse translator python translator to code morse pythob python text to morse and vice versa morse code binary python python convert binary to morse code translate binary to morse code python morse code to binary python morse to english python implement interanational morse code using pyhton text to morse and vice versa python python script to decode telegraph morse code python morse code generator decode the morse code python python morse code? 0 1 morse code dict python morse code bits python mpython morse code python list morse code python dictionary for translating morse python code for translating morse Create a function that takes a string as an argument and returns the Morse code equivalent. código morse python how to morse code in python mors code dictionary python from morse_dict import MORSE_2_ASCII def decode_morse(morse): how to decode morse code in python numbers in morse code dictionary python morse code to alphabet dictionary morse code to alphabet dictionary python morse code dictionary in python converting string to morse code dictionary def decode_morse(morse): decode morse in python morse code machine in python translator translate morse code python decode morse code python text to morse cide python library text to morse cide python morse to text python code morse dictionary python simple morse code translator in python code translator in python 3 morse code for number python code convert string of numbers to morse code python decode morse code to text python decode morse with python mose decoder python python code translator python morse code typer morse code writer python morse code python code morse decoder python ascii to morse python morse code decoder pythom text into morse code python all possible morse code decoding python morse code decoder python write a program that asks the user to enter a string and then converts that string to morse code project on morse code in python image morse code in python audi morse code in python morse code in python python english to morse code python morse code english to morse code how to make a morse program in python morse code to text python write a function that returns the Morse code sequence from a single letter python how to convert text to morse code with python morse code translator in python python morse dict morse code python library python morse code built in morse python morse code python that takes a list morse code translator python application morse code numbers and letters python dictionary abc and numbers to morse code python python morse code morse code encryptor and decrypt python punctuation in morse code python python morse code dictionary python morse code library morse code python devide with slashes morse code dictionary python morse code translator python python morse code translator decode the morse code python solution convert morse code to text python morse code python dictionary decrypt morse code python morse code decipher python morse code to english python morse code picture translator morse code python convert char to morse code python how to make a morse code translator in python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source