0

please check my code

i'm first time to python. so i making two different type multiplication table.  first i used to 'for', and succeeded. but used to 'while' i'm failure. why not this? help me #use 'for' for fn in range(1, 10): for bn in range(1, 10): print('%s * %s = %s' % (fn, bn, fn*bn)) #use 'while' cn = 1 sn = 1 while cn < 10: while sn < 10: print('%s * %s = %s' % (cn, sn, cn*sn)) sn += 1 cn += 1 this code result is just 1 * 1 = 1 . . . 1 * 9 = 9

29th Jun 2018, 2:40 AM
이진형
이진형 - avatar
2 ответов
+ 2
Hey, welcome to Python world! It's an awesome language ;) That's how this code should be: cn = 1 sn = 1 while cn < 10: while sn < 10: print('%s * %s = %s' % (cn, sn, cn * sn)) sn += 1 cn += 1 sn = 1 # Reset the multiplier to one everytime it gets to nine, until the multiplicand is nine too.
29th Jun 2018, 3:17 AM
Null
0
oh my gosh! thank u so much. haha god bless u.
29th Jun 2018, 3:23 AM
이진형
이진형 - avatar