Karmen Tamsalu
Karmen Tamsalu

Reputation: 11

Syntax error: in the "IF" block with Python

if new.upper() == "C":
            first()
        try:
            a, b, c = re.split(r"(\s+)", new)
        except ValueError:
            return

The syntaxs error occures to the colon behind "C". if new.upper() == "C": What can i do to fix this problem?

Upvotes: 0

Views: 37

Answers (1)

Steven Summers
Steven Summers

Reputation: 5384

Your indentation is incorrect. It should look like.

if new.upper() == "C":
    first()
    try:
        a, b, c = re.split(r"(\s+)", new)
    except ValueError:
        pass

Additionally use pass instead of return unless that snippet of code is inside a function. Because return can only be used inside a function.

Edit: Added in the correct indentation points

Upvotes: 1

Related Questions