PygLatin Exercise #4 - Check Yourself


#1



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


This is what I have gotten so far. I have tried everything else, but it just won't work. I don't understand what is wrong with my code. The error message that I keep getting is: "File python", line 4 | if len(original) > 0: | IndentationError: unexpected indent |

print 'Welcome to the Pig Latin Translator!'

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


#2

These two lines are in the same scope so should line up (with no indentation)

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

#3

The original variable is not the beginning of the if statement (as you can see, the variable declaration doesn't end with a colon (:)), so there's no reason to indent the if statement 4 spaces. Make sure you haven't mixed tabs and spaces either; spaces are the preferred indentation method.
The colons are there to declare the start of an indented block of code. In this case, the print statements.
Indentations to the left matter in Python. Remove the indentations of "if" and "else" (the else needs to be on the same level as the corresponding if).

The correct code would be:

print 'Welcome to the Pig Latin Translator!'

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

#4

@mtf and @aylamarianna - I see where I messed up. Thanks for helping! :grin: :sunglasses: