4. Check Yourself!


#1

I'm working on exercise 4. Check Yourself! (https://www.codecademy.com/en/courses/python-beginner-2W5v7/0/4?curriculum_id=4f89dab3d788890003000096#) and am getting a strange error message from my code.

#request for a word
raw_input("What's your favourite food?")
#assigning user input to original
original = raw_input
#if the user inputs less than 1 letter, return empty, otherwise print word
if len(original) > 0:
print original
else:
print "empty"

I'm then being returned this error:

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

Any and all help appreciated


#2

Realised that I didn't set my variable properly...

D'oh


#3

yea, you should combine this two lines:

raw_input("What's your favourite food?")
#assigning user input to original
original = raw_input

you want to store the raw_input in original:

original = raw_input("What's your favourite food?")

#4

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