PygLatin Code keeping previous raw_input and not using new!



My code will not use the raw_input that I enter when I hit run, instead it is using the previous input. So if I put in ‘Bob’ it will give me ‘obbay’ the first time but if I run it a second time to test a new word say ‘pie’ I get ‘obbay’ not ‘iepay’ if I run it again and put in ‘pie’ I will get ‘iepay’ but it isn’t giving me that the first time I put in a new word.

Just wanting to know if it’s my code or if it’s something to do with the exercise malfunctioning?


Here is my code:

pyg = 'ay’
original = raw_input(‘Enter a word:’)
new_word = word[1:len(word)] + first + pyg
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
print new_word
print ‘empty’

<do not remove the three backticks above>


Hi @fossilitic,

This statement is in the wrong place …

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

Notice that it depends upon the values of the variables word and first, and therefore will not execute correctly until those variables have been assigned values.

Place the statement after this one …

    first = word[0]


I was wondering if that might have been the problem. The instructions in the exercise were a little vague on where to place that line. Seems pretty logical NOW. Thanks for taking a look.