It works... not


The code works until I put the else and final print 'Empty.'.

The error message reads like this:
File "python", line 9
SyntaxError: invalid syntax

It should either print new.lower or if empty the exact word for it. Empty.

pyg = "ay"
answer = raw_input('Type a word in English:')
word = answer.lower()
first = word[0]
new = word[1:] + first + pyg

if len(answer) >= 1 and answer.isalpha():
    print new.lower()
    print "Empty"

Any ideas?

Edit: Code seems to work now.


Take a closer look at he error message. What is it saying?


When I change the unexpected indent (else has then the same indent as print new.lower, and the print (last line) has the same as else before. But then it says:


If you have corrected the first errorr,

check this part too make sure you have the correct syntax

You wrote

is answer an integer?


No answer is a variable. So...? How do check if there's at least one letter?


Answer is a string. How do you check the length of string? Also you are Missing parentheses on your .lower() call


Parentheses added. Thanks.
I have added len(answer) >= 1 and answer.isalpha(): instead of what I had before.

But error message is.

File "python", line 9
SyntaxError: invalid syntax


Can you update your original code snippet


Sure, it's done. Wasn't aware of editing possibilities after hours. Sorry.


The else block is still not indented correctly. It has to be inline with the if block.
You can check how to write if/else blocks in python


Code is updated. Seems to work. Thanks for your help!


Mark this thread as solved


Meaning? Selecting an answer as a solution? (Can't find anything else) You helped me out with more than one reply.


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