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 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.
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