for multiplier in range(5,8): for i in range(1,11): print i ,"x",multiplier,"=",i*multiplier print
#
我尝试将第2个for与第一个for对齐,但是程序就报错了
我的理解,如果拉齐后,就代表第二个程序块成为一个独立的程序块进行运行,这样print计算的时候就无法得到multplier的值,所以就无法完成计算
#result
C:\Python27\python.exe C:/Users/hunk/PycharmProjects/untitled/guess-number.py1 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 = 4510 x 5 = 501 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 = 5410 x 6 = 601 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 = 6310 x 7 = 70