This is my code:

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
   print original
word = original.lower()
first = word[0]

  print 'empty'

This is the error:

File “python”, line 10
SyntaxError: invalid syntax

It also says: Did you create a variable called word?

What am I doing wrong? Thanks.


I would pay more attention to the syntax error then codecademy’s error message

else has to be after a an if condition (or elif), which its currently not. Currently its after a line where first variable is defined.


Thank you. I think I was confuse by the instructions:
Inside your if statement: create…
And I didn’t consider “else” as part of the if condition.

Now it works. Thank you for your help.


nesting is important for the flow of your program

its not part of the if condition, but if condition do something, else do something different. if, elif and else belong together/are related, but i wouldn’t define/describe it as part of


Now it is more clear for me. Thanks!


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