a = [[‘apple’, ‘orange’, ‘banana’, ‘grape’], (1, 2, 3)]
for x in a:
for y in x:
if y == 'orange':
break
print(y)
else:
print(‘fruit is gone!’)
**问题一:**break终止了当前循环块到底是什么意思?如果划分每一步骤的话,程序实际上每一步是怎么走的呢?
如果我更改了一下print(y)的缩进,最后打印了“orange”, "3"以及“fruit is gone!”
a = [[‘apple’, ‘orange’, ‘banana’, ‘grape’], (1, 2, 3)]
for x in a:
for y in x:
if y == 'orange':
break
print(y)
else:
print(‘fruit is gone!’)
**问题二:**这又是因为什么呢?