关于while 循环
for i in range(10):for j in range(10):
while (i==0 or j==0):
continue
print (str(i) + " x " + str(j) + " = " + str(i*j))
为什么这个不会输出任何值吗,i和j在一个范围10里面会不会改变(从0-9) 本帖最后由 suchocolate 于 2021-10-7 11:19 编辑
i和j开始都是0,while成立,执行while中内容,然后里头只有continue,i和j的值没有改变机制,while又成立,又执行while中的continue,死循环。 [[, print()] for j in range(10)] 0 x 0 = 01 x 0 = 02 x 0 = 03 x 0 = 04 x 0 = 05 x 0 = 06 x 0 = 07 x 0 = 08 x 0 = 09 x 0 = 0
0 x 1 = 01 x 1 = 12 x 1 = 23 x 1 = 34 x 1 = 45 x 1 = 56 x 1 = 67 x 1 = 78 x 1 = 89 x 1 = 9
0 x 2 = 01 x 2 = 22 x 2 = 43 x 2 = 64 x 2 = 85 x 2 =106 x 2 =127 x 2 =148 x 2 =169 x 2 =18
0 x 3 = 01 x 3 = 32 x 3 = 63 x 3 = 94 x 3 =125 x 3 =156 x 3 =187 x 3 =218 x 3 =249 x 3 =27
0 x 4 = 01 x 4 = 42 x 4 = 83 x 4 =124 x 4 =165 x 4 =206 x 4 =247 x 4 =288 x 4 =329 x 4 =36
0 x 5 = 01 x 5 = 52 x 5 =103 x 5 =154 x 5 =205 x 5 =256 x 5 =307 x 5 =358 x 5 =409 x 5 =45
0 x 6 = 01 x 6 = 62 x 6 =123 x 6 =184 x 6 =245 x 6 =306 x 6 =367 x 6 =428 x 6 =489 x 6 =54
0 x 7 = 01 x 7 = 72 x 7 =143 x 7 =214 x 7 =285 x 7 =356 x 7 =427 x 7 =498 x 7 =569 x 7 =63
0 x 8 = 01 x 8 = 82 x 8 =163 x 8 =244 x 8 =325 x 8 =406 x 8 =487 x 8 =568 x 8 =649 x 8 =72
0 x 9 = 01 x 9 = 92 x 9 =183 x 9 =274 x 9 =365 x 9 =456 x 9 =547 x 9 =638 x 9 =729 x 9 =81
页:
[1]