Pyglatin syntax error in else: statement


#1



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

I try to run the code below and I get the folloeing error:
File "python", line 7
else: print "empty"
^
SyntaxError: invalid syntax

Am I missing something about the if/else statements?


print 'Welcome to the Pig Latin Translator!'

name = raw_input('What is your name?')
original = raw_input("Type any word:")
if len(original) > 0:
print ("Now you can play PygLatin!")
else:
print ("empty")


#2

you have to have an .isalpha() check in your first if statement. Like so

And after the user inputs their name what are you planning on doing with it?


#3

I ran it with your line and got the exact same error. As far as the namne is concerned, I don't really know, it is just there from the previous parts of the task...


#4

Sorry I took you ahead of an excercie.

What you should do is instead of printing a string

After your if statement print original so your code should look like this

print 'Welcome to the Pig Latin Translator!'

name = raw_input('What is your name?')
print "Oh hi! " + name  + "."
original = raw_input("Type any word:")
if len(original) > 0:
    print original
else:
    print ("empty")

#5

Worked just fine, thank you very much


#6

you're welcome :slight_smile: