Check Yourself; Traceback & Type errors


I have been stuck with the following issues for the last week now and after several tweaks and adjustments, I am still getting the same errors. These errors have something to do with Traceback and TypeError?!

Here is my code:
raw_input("Enter a word:")
original= raw_input

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


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

Help would be greatly appreciated!


This statement should be part of ,

this one,

All one like,

original= raw_input("Enter a word:")

And here,

You are supposed to print original to the console not raw_input.

raw_input is a function and cannot be printed like a variable.


Ah okay I see now, that does make more sense.
Thanks very much


print 'Welcome to the Pig Latin Translator!'

Start coding here!

original = raw_input("Enter a word")
if len(orignal) > 0:
print "original"
else :
print empty

what am i doing wrong here


You put quotes around original in here:

Even though it is not suppose to be a string. Remove them. Also you need quotes around empty in here:

Because it is suppose to be a string. That should fix your problem. :slight_smile:


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