Pyg Latin Move it on back HELP!


Move it On back

Oops! Did you accidentally delete the word variable?
Traceback (most recent call last):
File "python", line 2, in
NameError: name 'word' is not defined

I think it should rearange the word but it gives me that error message...

pyg = 'ay'
new_word = word + first + pyg

original = raw_input('Enter a word:')

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


new_word = word + first + pyg

You're trying to add (concatenate to be precise) first and word with new_word without defining them!


x = y + z

y = 4
z = 56
print x # it will throw an error [NameError]

as we defined x without defining y and z.
It will throw an error!

But .....

y = 4
z = 56
x = y + z
print x # it will not throw any error

as we defined x after defining y and z.
It will not throw an error!

from above example we learnt that new_number should be after first and word (after u define them)


Oh I see, thanks a lot man! So I should put it at the end of the code, but it says the first part of the code.


As you can see and I already mentioned that you've to definenew_name after you define word and first variables.

Put this after you define (word and first variable insideif statement!)
new_word = word + first + pyg

There is one more thing that you have to do tho ..

Read the instruction!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.