Check Yourself


#1



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


Welcome to the Pig Latin Translator!
Enter a word: sdfdf
Traceback (most recent call last):
File "python", line 4, in
TypeError: object of type 'builtin_function_or_method' has no len()


What is the error with line 4? Everything seems to be correct.


print 'Welcome to the Pig Latin Translator!'
raw_input("Enter a word:")
original = raw_input
if len(original)>0:
    print original
else:
    print "empty"


#2

These two lines should be one in the sense that,

original is just a variable that will store raw_input("Enter a word:") the user's input.

So it would just be,

original = raw_input("Enter a word: ")


#3

this line set to the variable named original
raw_input("Enter a word:")

you have two raw_input should be one .so your code should look like

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

#4

The error is that raw_input is always meant to be assigned to a variable. So on line 2 that raw_input statement is meant to be in the variable "original" on line 3. If you do that then it will work.


#5

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