Pyg Latin Move it on back HELP!


#1


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


#2

new_word = word + first + pyg

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

example...

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!

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


#3

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.


#4

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 ..

hint**
Read the instruction!


#5

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