r/pythontips • u/[deleted] • Feb 08 '21
Python3_Specific Morse Code Machine
Hello there! I've started learning python yesterday. I'mm trying to creae a morse code translation. I had some troubles at first, but it looks like that everything is working fine. I would be glad if anyone could gibe me some suggestions. I will look for standars and improove it on the code. I also would like to get some tips on how to abolish the two first options on the menu and create a function that can automatically detect if the user inserted an alphabetic text or a morse coee one.
Git Hub link: https://gist.github.com/VitorGRM/7c5165831224bcadb6c76f06c1fdaccb
29
Upvotes
2
u/blowingmindssince93 Feb 08 '21 edited Feb 08 '21
Hi! Nice job it does what it needs to and for someone who started yesterday it's looking good! I'm sure there's other people with more experience that will weigh in on some of the standards etc I was just going to make a suggestion for your point about automatically identifying if it is more code or words, python has isalpha() which checks if the thing inside it is an alphabetic character I'd think an easy way to achieve what you want would be something like
If isalpha(input_phrase) :
Print(Codify(input_phrase))
Else:
Print(decodify(input_phrase))