What am I doing wrong



print 'Welcome to the Pig Latin Translator!'
Next we need to ensure that the user actually typed something.

empty_string = ""
if len(empty_string) > 0:
# Run this block.
# Maybe print something?
# That string must have been empty.
We can check that the user's string actually has characters!

Write an if statement that verifies that the string has characters.

Add an if statement that checks that len(original) is greater than zero. Don't forget the : at the end of the if statement!
If the string actually has some characters in it, print the user's word.
Otherwise (i.e. an else: statement), please print "empty".
You'll want to run your code multiple times, testing an empty string and a string with characters. When you're confident your code works, continue to the next exercise.


Start coding here!

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


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

the error message


Hello :slight_smile:

Take a look at these two lines:

raw_input("Enter a word:")
original = raw_input

The first one says "get input from user and do not store it anywhere", the second says "assign function raw_input to the original object".

So what is the length of the raw_input function? No one knows :smiley: That is what the error message says.

You need to join these two lines into one statement:

original = raw_input("Enter a word:")

Now original will held the value inputted by the user.


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