+ 4

Need improvement on Multiplication table

Hello pls, I need help with coding A multiplication table using Python. I av done something but it needs improvement, what i need is two input, one that enters the last row you want and the other that enters the last column you want and output the multiplication table Here is my code: a = int(input('Enter the last row you want ')) c = 1 d = 1 print(list(range(c,a+1,d))) for i in (range(c,a,d)): i = i+1 c = c + 1 a = a + (12+1) d = d + 1 print(list(range(c,a,d))) https://code.sololearn.com/cRo6x8gSpHnX/#py

19th Aug 2019, 4:55 PM
elvisreal
elvisreal - avatar
15 Answers
+ 10
At SoloLearn you must use a new line for the second input. Your code works fine. Maybe you could make it a little bit pretty, but it works. Have a look at this one: https://code.sololearn.com/cL41qXwD7Mzc/?ref=app
3rd Oct 2019, 6:14 PM
Worm
Worm - avatar
+ 4
Thank you..really helpful
20th Aug 2019, 2:26 AM
elvisreal
elvisreal - avatar
+ 4
Corrected it, it works! thank uuu sir Paul Jacobs
21st Aug 2019, 4:17 AM
elvisreal
elvisreal - avatar
+ 4
a = int(input('Enter the last row you want ')) b = int(input('Enter the last column you want ')) c = 1 d = 1 e = a+1 print(list(range(c,e,d))) for i in (range(c,b,d)): i = i+1 c = c + 1 e = a*i d = d + 1 print(list(range(c,e+1,d)))
21st Aug 2019, 4:17 AM
elvisreal
elvisreal - avatar
+ 3
done that.
19th Aug 2019, 5:37 PM
elvisreal
elvisreal - avatar
+ 3
Yea in that order
19th Aug 2019, 6:05 PM
elvisreal
elvisreal - avatar
+ 3
Do you want a code that works, more or less, or do you want instructions, so you do it yourself?
19th Aug 2019, 7:17 PM
Paul
Paul - avatar
+ 3
Paul Jacobs, now i need instructions :)
20th Aug 2019, 2:43 AM
elvisreal
elvisreal - avatar
+ 3
Thank you sir Paul Jacobs, I made this changes but it didn't give me the desire result: a = int(input('Enter the last row you want ')) b = int(input('Enter the last column you want ')) c = 1 d = 1 e = a+1 print(list(range(c,e,d))) for i in (range(c,b,d)): i = i+1 c = c + 1 e = a+i d = d + 1 print(list(range(c,e,d)))
20th Aug 2019, 7:51 PM
elvisreal
elvisreal - avatar
+ 3
:)
21st Aug 2019, 10:43 AM
elvisreal
elvisreal - avatar
+ 2
Do you want your in and output like this: ''' input : 5 (rows) 3 (lines) gives you: 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 '''
19th Aug 2019, 5:41 PM
Paul
Paul - avatar
+ 2
You need a second input variable b like a for the number of lines And you need a new variable e to calculate the maximum in the range for each line. The max range value in the for loop should be b (the number of lines), it is now a. The max range value in the print statement should be e, it is now a. You should calculate e using a and i in the loop (and replace a = a + (12 + 1)).
20th Aug 2019, 7:39 AM
Paul
Paul - avatar
+ 2
It should be e = a * i in the for loop.
20th Aug 2019, 8:01 PM
Paul
Paul - avatar
+ 2
Well done.
21st Aug 2019, 6:37 AM
Paul
Paul - avatar
+ 1
rows = 5 # int(input()) lines = 3 # int(input()) for i in range(1,lines+1): print(list(range(i,i*(rows+1),i)))
19th Aug 2019, 7:44 PM
Diego
Diego - avatar