Error


#1


File "python", line 10
else: print "empty"
^
IndentationError: unindent does not match any outer indentation level


print 'Welcome to the Pig Latin Translator!'

# Start coding here!
raw_input("Enter a word:")
original = raw_input()

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


#2

This needs to be in line with the if statement, so it would look like:

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
raw_input("Enter a word:")
original = raw_input()

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

because indentation is part of how python interprets things.


#3

I think you mean

else:
    print empty

#4

no, if your else clause is a single line you can put it on the same line as the else keyword. (same obviously goes for if)

you could even use a ternary operator, which is the following:

print "original" if len("original") > 0 else "empty"

so what ashery and kyleaw do is perfectly valid


#5

oh ok, thank you for teaching me :blush:


#6

Typically, i will never avoid line breaks, but I was trying to keep @ashery 's code the same without changing much sinse it was theirs and not mine.


#7

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