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
2 Answers
+ 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.
0
oh my gosh! thank u so much. haha god bless u.