Ending Up Error



Hi All,

Can u advise where what's going wrong?

I wrote the below gives the exact result as expected however, throws out an error??


_wordpyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
print original
name = original.lower()
print word
first = name[0]
print first
word = (name + first + _wordpyg)
print word
new_word = word[1:]
print new_word

print 'empty'


Output as below

Enter a word: RAJ

Error as Below :

Oops, try again.
word should contain the .lower()-case version of original.

Please advise.



Your code would run fine as it is. For this exercise, however, the interpreter accepts only a specific format of the program. At the end of the execution, a few conditions must be met for the interpreter to accept your code. One of them is the word variable must contain only the lower-case version of the original.

Even though your code would work in another environment, the line where you set word = (name + first + _wordpyg) throws an error because this does not satisfy the condition for the word variable that is checked at the end.

Additionally, you should use the variable word instead of name in the beginning so the interpreter does not throw an error.

Instead, why don't you just use new_word to contain word[1:] + first + wordpyg? Then go from there, and you should be good.

Hope this helps!

P.S. This may have changed, as I tried to run your code as-is, and it ran fine for me in the CodeAcademy interpreter. Even so, it is good to remember that satisfying the exercise conditions is important.


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