Beginner here. I'm playing around with the dictionary function, and I am trying to build a basic translator.
However, it seems to only translate one word correctly.
This is the code:
english = input("Type in a sentance: ").lower()
"""
DICTIONARY
"""
portuguese = {
# Greetings
"hello": "olá",
# Article
"the": "o"
}
portu_output = ""
for eng_word in english:
portu_output = portuguese.get(english, eng_word) + " "
print(portu_output)
When I write one word in the input, "Hello", the output will translate successfully, "olá".
But when I write two words, both items of the dictionary, such as "Hello the" together, the output will only print out the last letter of those words.
"Hello the" will only be printed out as "e", or "the hello" will only be printed out as "o".
I wonder where I went wrong. Thanks.