Python “expected an indented block”

前端 未结 9 1196
广开言路
广开言路 2020-12-09 08:00

Let me start off by saying that I am COMPLETELY new to programming. I have just recently picked up Python and it has consistently kicked me in the head with one recurring e

9条回答
  •  甜味超标
    2020-12-09 08:43

    in python .....intendation matters, e.g.:

    if a==1:
        print("hey")
    
    if a==2:
       print("bye")
    
    print("all the best")
    

    In this case "all the best" will be printed if either of the two conditions executes, but if it would have been like this

    if a==2:
       print("bye")
       print("all the best")
    

    then "all the best" will be printed only if a==2

提交回复
热议问题