UPDATE
If you are having trouble with exercise 4 then this is the thread that explains it all. If you read towards the end of the conversation you will see that @albionsrefuge confirms that this is a bug in the course. Unfortunately due to response times it seems it is very unlikely that it will be fixed. Please read to see the correct syntax to the exercise but I encourage you to do additional research to understand the context because I overlooked this myself and now that I have gone back over my notes it makes perfect sense.
Original Post
Please keep in mind that when you start this section that it starts with the following code:
print 'Welcome to the Pig Latin Translator!'
# Start coding here!
raw_input("Enter a word:")
original = raw_input
Yesterday I was working through the Python module and started the Pig Latin section. When I got to section 4. Check yourself! I ran into a problem. The code appears to be correct but it will return the following error:
Traceback (most recent call last):
File “python”, line 9, in
TypeError: object of type ‘builtin_function_or_method’ has no len()
I have done some research to try and figure out why this is a problem. I have seen solutions that suggest to use the .isalpha() function but I think this is suppose to be for the next section 5. check yourself… some more. Len() according to the Python site states that this only checks to see how many in what ever variable you call so this should come back as true statement. I have seen suggestions made saying that an additional set of parentheses should be added to the function raw_input when saving it to the variable in line 6 (see code below) so that it appears as “original = raw_input()” but all this does when I run the code is prompt me for another input.
# Welcome Message for user
print 'Welcome to the Pig Latin Translator!'
# asking user for input
raw_input("Enter a word:")
original = raw_input
# Time to verify that user entered valid characters
if len(original) > 0:
print original
else:
print "empty"
The next day I came back to try this again and found that I was automatically in the next section 5. Check yourself… some more. I returned to the previous section as soon as I realized that I was in the next section without resolving the problem I was having the previous day. After some more research I began to suspect that this was a bug and my code was not at fault. Eventually I tried the following code as well as found a reference that confirmed my suspicion that this is a bug in the module…
# Welcome Message for user
print 'Welcome to the Pig Latin Translator!'
# asking user for input
original = raw_input("Enter a word:")
# Time to verify that user entered valid characters
if len(original) > 0:
print original
else:
print "empty"
My References: