Invalid syntax on VERY SIMPLE Python if … else statement

后端 未结 7 1802
走了就别回头了
走了就别回头了 2021-01-13 20:05

Can someone explain why I am getting an invalid syntax error from Python\'s interpretor while formulating this simple if...else statement? I don\'t add any tabs myself I sim

7条回答
  •  说谎
    说谎 (楼主)
    2021-01-13 20:28

    That's because your else part is empty and also not properly indented with the if.

    if 3 > 0:
        print "voila"
    else:    
        pass
    

    In python pass is equivalent to {} used in other languages like C.

提交回复
热议问题