Check Yourself syntax error


#1



I'm stuck on Check Yourself


I get invalid syntax error on my 7th line, my "else" line. I have zero clue what is wrong with my code, I've tried putting colons in various spots, tried putting empty inside and outside of quotations, tried indenting more and less and can't figure it out


print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("Enter a word")
if len(original) > 0:
    print original
    else print "empty"


#2

The syntax for an if/else statement is

if condition:
    code-to-execute
else:
    code-to-execute

#3

The indents is wrong and you need colons for the else statement. It should be like this:

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("Enter a word")
if len(original) > 0:
    print original
else:
    print "empty"

#4

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