cardei
cardei

Reputation: 11

Python syntax error for a simple if statement

I get a syntax error in my if statement:

print "Welcome to the English to Pig Latin translator!"

original = raw_input("Please enter a word to be translated: ")
word_length = len(original)

def length_check():
    If (word_length) > 0 : <-- This colon brings up the following error:
        return original


File "python", line 7
    If (word_length) > 0 :
                         ^
SyntaxError: invalid syntax

Upvotes: 0

Views: 404

Answers (1)

Sukrit Kalra
Sukrit Kalra

Reputation: 34531

If should be changed to if. Observe the lowercase i.

>>> If True:

SyntaxError: invalid syntax
>>> if True:
        print True


True

You may want to read up The Python Doc's entry on Control Flow.

Upvotes: 5

Related Questions