Python-error-object-of-type-builtin-function-or-method-has-no-len


#1



pyg latin --> Check Yourself!


Receive the error python-error-object-of-type-builtin-function-or-method-has-no-len. I just want to understand why the example below doesn't work. I figured out how to make it work by looking at others posts however I don't quite get why the one is correct and the other is not. The break down worked fine in the previous exercise is where my confusion is.


Doesnt Work

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
raw_input("Enter a Word:")
original = raw_input

if len(original) > 0:
    print original
else:
    print "empty"

Works

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("Enter a Word:")


if len(original) > 0:
    print original
else:
    print "empty"


#2

Think for a moment about what that says "function or method has no length", what does that suggest that you did?

And if you think your two versions are equivalent, then you've got some kind of argument for why that would be, right? What is that argument?


#3

I am assuming it is is because I am recalling the function on line 2 and setting the value to the function or nul.


#4

I dont have an argument as much as I was just trying to understand the why of what was wrong.


#5

And I'm trying to approach it from the other side; why would it be right? If you ask me why broccoli doesn't fly, then I'd like to know why you think it would before I tried to explain that. Or if you can't argue for why broccoli would fly, then that's an answer by itself.


#6

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