简体   繁体   中英

if statement error: invalid syntax and expected an indented block

When executing my code below I get a syntax error:

expected an indented block

I have checked the tabs are not spaces as suggested on other threads. What is causing this?

if wallDirection = '-X':
    xAxis = -buildingSectionWidth

First see What is the difference between an expression and a statement in Python? An if statement requires an expression as its condition.

wallDirection = '-X' is a statement that assigns wallDirection to the value -X . The expression you likely want here is wallDirection == '-X' . The operator that tests for equality is == , not = .

if wallDirection == '-X':
    xAxis = -buildingSectionWidth

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM