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


#1



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


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
else:
    print 'empty'


#2

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:


#3

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!


#4

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: