Translates the previously entered word, not the current one


#1



https://www.codecademy.com/courses/python-beginner-2W5v7/1/5?curriculum_id=4f89dab3d788890003000096


When re-running my code if I change the word then it gives me the translation for the previous word. If I then run it again with the same word it will come out correctly translated. So basically I have to run the same word twice to get the correct translation. Or, put another way. it is translating the last word instead of the current one.

Any ideas what I did wrong?


pyg = 'ay'
new_word = word + first + pyg
new_word = new_word[1:]

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    print original
    word = original.lower()
    first = word[0]
    print new_word
else:
    print 'empty'


#2

Those lines should be inside the if statement, just above the print new_word.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.