Word Up


#1

I'm stuck on PygLatin exercise 8, Word Up

When I run my code, it says "Oops, try again. Did you create a variable called word?"

In the console, it shows this:
Traceback (most recent call last):
File "python", line 3, in
TypeError: 'str' object is not callable

Here is my code:

pyg = 'ay'

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

First of all, that's the code:

pyg = 'ay'

original = raw_input('Enter a word:')

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

You positioned "print original" on the wrong line.


#3

Nope, still doesn't work


#4

Weird. Try using a different browser. For me it works in Firefox/Chrome.

As a remember, here's the full code:

pyg = 'ay'

original = raw_input('Enter a word:')

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


#5

I'm using chrome right now. I tried deleting the code and replacing it with what you gave and it still wonk work. I just don't think I'm able to carry on with the lesson at the moment. Later I'll try on a different computer/browser


#6

I found the problem.
When you copy the code directly from the forum, the spacing or the way the code is 'aranged' , is wrong. I tried the same code, but typing everything over instead of copy-paste, wich worked. Copying over didn't work for me either.


#7

Useful, thanks. I had the same problem.

The only question I have now is why the code won't work if the two variables (word and fist) are placed before the print statement. I thought it wouldn't make a difference?


#8

Replace
print original by
print word


#9

pyg = 'ay'
word = original.lower()
original = raw_input('Enter a word:')
first = word[0]
if len(original) > 0 and original.isalpha():
print original
else:
print 'empty'

This is the correct coding for it. It will have an error the first time you type a word in, so you have to type the same word twice. For example, when it says "Enter a word:" type any word in. You will get an error the first time, but don't change the code. Just hit the submit button again and type the same word that you used before.


#10

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