Im working on a translator (english to braille) as a project for a class in python 2.7. We've been essentially thrown to the wolves and I've never had experience coding before. How in the hell am I supposed to create a function that iterates through one dictionary and spits out the value for each letter in english(only one dictionary so I get the general idea)?
Ive got a comfortable 3 dictionaries for each row that a braille letter takes to make, and im honestly just not sure where to start in terms of the function. Ive got a prompt asking for a word, but idk how to make python look at individual letters in a word and reference those letters to a dictionary.
eng_to_braille_1 = {
'a': '. ', 'b': '. ', 'c': '..', 'd': '..', 'e': '. ', 'f': '..', 'g': '..', 'h': '. ', 'i': ' .', 'j': ' .', 'k': '. ', 'l': '. ', 'm': '..', 'n': '..', 'o': '. ', 'p': '..', 'q': '..', 'r': '. ', 's': ' .','t': ' .', 'u': '. ', 'v': '. ', 'x': '..', 'y': '..', 'z': '. '
}
eng_to_braille_2 = {
'a': ' ', 'b': '. ', 'c': ' ', 'd': ' .', 'e': ' .', 'f': '. ', 'g': '..', 'h': '..', 'i': '. ', 'j': '..', 'k': ' ', 'l': '. ', 'm': ' ', 'n': ' .', 'o': ' .', 'p': '. ', 'q': '..', 'r': '..', 's': '. ','t': '..', 'u': ' ', 'v': '. ', 'x': ' ', 'y': ' .', 'z': ' .'
}
eng_to_braille_3 = {
'a': ' ', 'b': ' ', 'c': ' ', 'd': ' ', 'e': ' ', 'f': ' ', 'g': ' ', 'h': ' ', 'i': ' ', 'j': ' ', 'k': '. ', 'l': '. ', 'm': '. ', 'n': '. ', 'o': '. ', 'p': '. ', 'q': '. ', 'r': '. ', 's': '. ','t': '. ', 'u': '..', 'v': '..', 'x': '..', 'y': '..', 'z': '..'
}
word = input("Type a word to be translated: ")
word = str()
def translate(word):
translation = ""
You can define the inside function like this:
The top row, middle & bottom row will be printed. But this cant be done for long string input. For that, you better find unicode for braille.