Remembers previous input, not returning current correct answer


#1



PygLatin 11/11

I am not receiving an error, but when I try to change the word to translate in the code, it will give me the previous word's answer... when I input a blank, it does return the empty... but it seems to be remembering the previous word and translates that instead


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

original = raw_input('Enter a word:')

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

is there something I can change in my code to return the most current word input?

Thanks!


#2

@scriptsolver00307: That's because you are, by no meaning, altering the value stored in the variable new_word so you're printing the "old" entry (and such doesn't see to get anything since word wasn't declared, lets say it like this, at any part before using your code).

Edit: try placing that segment of code inside your if statement so it will bring back the correct output.


#3

That fixed it, thank you @g4be !!