Ending Up. Again


#1

Posted about this before, and had one problem resolved, but now I have another.

Error

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

Code

pyg = 'ay'
original = raw_input('Enter a word:')

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

I cannot tell where I am going wrong here. Support?


#2

here:

new_word = new_word[1:len(new_word)]

you define new_word, but you also take a slice of new_word (while defining it) that doesn't work


#3

So how do I go about it? Do I make separate variables to define and slice?


#4

you defined new_word in the previous exercise (9. move it back), why did you remove it?

then here you take a slice of new_word which you defined in the previous exercise


#5

I read another forum post saying replace the new_word variable with the new code. It worked the OP but I couldn't get it working. Now I understand, thank you.


#6

you need to update/re-assign new_word, but not remove your new_word which was already there


#7

Did it, finished the course. Also, added print new_word which I had forgotten until the end.


#8

Well done :slight_smile:


#10