python问题:IndentationError:expected an indented block错误解决

对100以内的两位数,请使用一个两重循环打印出所有十位数数字比个位数数字小的数,例如,23(2 < 3)。

for x in [1,2,3,4,5,6,7,8,9]:   
    for y in [0,1,2,3,4,5,6,7,8,9]:       
    if x < y :        
    print x *10 + yFile "", line 4
print x *10 + y
         ^

IndentationError: expected an indented block

Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中。最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的。

在编译时会出现这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行。

往往有的人会疑问:我根本就没缩进怎么还是错,不对,该缩进的地方就要缩进,不缩进反而会出错。

解决方案:

for x in [1,2,3,4,5,6,7,8,9]:
    for y in [0,1,2,3,4,5,6,7,8,9]:
        if x < y :
            print x *10 + y

如果有错误,请指正,如果有问题,欢迎讨论,共同进步!

你可能感兴趣的:(python问题:IndentationError:expected an indented block错误解决)