使用字串作為迴圈迭代的物件 <<
Previous Next >> Day18(0202)
巢狀for迴圈
使用巢狀for迴圈列出九九乘法表,如下。
result1,result2 = '' , ''
for i in range (1,10):
result1 = ''
for j in range(1,10):
result1 = result1 + str(i) + '*' + str(j) + '=' + str(i*j) + '\t'
result2 = result2 + result1 + '\n'
print (result2)
使用字串作為迴圈迭代的物件 <<
Previous Next >> Day18(0202)