I am relatively new to python and am having a hard time with an assignment. We just started using dictionaries and I can't quite grasp what is going on. I am just having trouble figuring out where to even start exactly. This is the code my teacher gave me and he wants us to build off of it
def buildMorseDicts(morseFile):
'''build and return dictionaries to translate to and from Morse code'''
toMorse = {}
fromMorse = {}
# finish this code then remove this comment
return (toMorse, fromMorse)
def encode(word,toMorse):
'''creates a string of . and _ characters to encode each character
in word to Morse code using the toMorse dictionary. A space is placed
between each string of . and _ that represent a Morse character in
the encoded version.'''
morse = ""
# finish this code then remove this comment
return morse
def decode(morseWord,fromMorse):
'''creates a string of english letters that are the decoded version of
each space-separated sequence of . and _ characters in morseWord string.'''
english = ""
# finish this code then remove this comment
return english
def main():
# Open the file with the translation between regular characters and Morse code
filObj = open("morse.txt", 'rU')
toMorse, frMorse = buildMorseDicts(filObj)
filObj.close() # Close the file when finished with it.
# Open the file to translate from text to Morse code
filObj = open("morse1.txt", 'rU')
for word in filObj:
print encode(word,toMorse)
filObj.close() # Close the file when finished with it.
# Open the file to translate from text to Morse code
filObj = open("morse2.txt", 'rU')
for word in filObj:
print decode(word,frMorse)
filObj.close() # Close the file when finished with it.
main()