Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f=open("sequence.txt")#sequence.txt contains all the alphabets and characters which should be converted to morse in the same order as the pdf in the OP
- normalCharacters=[]
- for i in range(1,43):
- normalCharacters.append(str(f.readline().replace('\n','')))
- f.close()
- f=open("morse.txt")# morse.txt contains each character converted to morse copied from the pdf
- characterInMorse=[]
- for i in range(1,43):
- s=str(f.readline())
- s=s.replace('\n','')
- characterInMorse.append(s)
- print "Please enter the string to be converted into morse."
- userInput= str(raw_input()).upper()#inputting from the user
- morsecode=""# will be used to store string in morse
- for ch in userInput:
- if ch==' ':
- morsecode=morsecode+" "#if a word ends two spaces are added
- else:
- if ch=='(':
- morsecode=morsecode+characterInMorse[41]
- continue
- if ch==')':continue
- index=normalCharacters.index(ch)
- morsecode=morsecode+characterInMorse[index]
- morsecode=morsecode+" "
- print "In Morsecode:"
- print morsecode
- #contents of sequence.txt http://pastebin.com/ttXGLTn0
- #contents of morse.txt http://pastebin.com/TUdmSKPt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement