用for迴圈, range()
for i in range(1, 10):
for j in range(1, 10):
num = i * j
print('%d x %d = %d' %(i, j, num))
print('\n')
用for迴圈, 但自定義list, 不使用range()
list = [1,2,3,4,5,6,7,8,9]
for i in list:
for j in list:
num = i * j
print('%d x %d = %d' %(i, j, num))
print('\n')
用while迴圈
i = 1
while i < 10:
j = 1
while j < 10:
num = i*j
print('%d x %d = %d' %(i, j, num))
j += 1
i += 1
print('\n')