I am trying to translate I am Jason using this code, but when I use it, it prints out nothing, unless I do one word like hello, then it prints out guten tag, but that's it. Plus, I can't turn the input data into lowercase to be able to compare it to the dictionary. What can I do to make this code work?
name = input("Please enter your name\n")
data = [input("Please enter sentence\n")]
data = data.lower() #to make sentence lowercase to be able to compare it to the words in the dictionary
dictionary = {"hello": "hallo", "i" : "ik", "am" : "ben"}
dictionary[name] = name
for word in data:
if word in dictionary:
print (dictionary[word],)
This is the traceback
*Please enter your name
Jason
Please enter sentence
I am Jason*
Traceback (most recent call last):
File "C:/Users...", line 3, in <module>
data = data.lower()
AttributeError: 'list' object has no attribute 'lower'