Testing,Testing, is This Thing On? *don´t understand what´s wrong



The code I did is giving me back the error

Traceback (most recent call last):
File "python", line 7, in
NameError: name 'new_word' is not defined

it was working at one point but i guess i did something accedentally and didn´t notice what and now i cannot fix it

original = raw_input('Enter a word:')

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


This line right here should be before anything else. It is not mandatory but it's easier to understand and looks better that way.
And after first = word[0] you need a new_word variable that adds word + first + pyg like so,

new_word = word + first + pyg

That's all. :slight_smile:


I just thought that pyg variable looks better among other variables that makeup the new_word but I´ll take the advice.
Anyway, thank you. Now it´s working perfectly!


Your most welcome! As long as your code works as it should you can put the pyg variable where you like but if you're getting errors correcting the way your code is arranged makes it easier to debug your code. :slight_smile: