Check yourself TypeError: object of type 'builtin_function_or_method' has no len()


#1


https://www.codecademy.com/courses/python-beginner-2W5v7/0/4?curriculum_id=4f89dab3d788890003000096#

raw_input("")
original=raw_input

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


#2

I am not 100% sure what your error is stemming from but I think the raw input function is the culprit. It takes the user input and turns it into a string. You can assign that input to a variable in one line. eg.

original=raw_input("enter a word")

this will have "enter a word" pop up in the terminal and when you type your word it will be assigned to original.

also you do not need to declare empty_string. you can do that on the fly when you start with the string modulation.


#3

okay thank you! ill will try and see if it works and let you know.:grin:


#4

Traceback (most recent call last):
File "python", line 6, in
TypeError: object of type 'builtin_function_or_method' has no len()

i still get the same error

raw_input("fish")
original=raw_input

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


#5

so i thought i was prevously replying to you, but it turns out that you can directly reply to the person lol. uhhh anywho i did was you said and im still getting the same error :confused:


#6

wait nvm i was ding dong and forgot to put the raw_input on just one line.. it wokred :smiley:


#7

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