![]() ![]() I know this is an old question but in the tradition of open source I wrote code to implement the fact that Morse is a binary tree and this may be faster than using a dictionary: class node:Įlif char = '-' and basenode.dash is None:ĭef insert(self, basenode, key): # val = tuple ('P','.-.')ĭef decode(self, basenode, tone): tone is a morse string Here is my code # defines the dictionary to convert morse to englishĬODE_reversed = ġ- Use / to separate the letters and space to separate words.Ģ- Your message must contain only letters and numbers.ģ- '?' in output means that your input was unknowed. ![]() ![]() I'm new to Python and dictionaries and i don't know how to differeniate between an E "." and an S "." when searching my dictionary I tried to fix this by detecting spaces and doing it a word at a time, but instead of looking for the letters in the word it searches the entire word against the dictionary I have attempted to do it one charecter at a time, but the problem is that morse code letters are not 1 charecter long like english letters, so E is "." and S is ".", the problem i have is that the dictionary loop will find the "." and match it to E, so instead of getting S i get "E E E" I have managed to convert english to morse code using thisīut i want to convert Morse Code to English I want to convert Morse Code to English using Python 3+ ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |