#207 · Loops · Beginner · 25 XP · about 4 min
Write times_table(n) that returns the times table for n as a list of 10 strings, from n times 1 up to n times 10. Each line looks exactly like '3 x 4 = 12': the number, a space, a lowercase x, a space, the multiplier, a space, =, a space and the product.
times_table(3) # returns ['3 x 1 = 3', '3 x 2 = 6', '3 x 3 = 9', '3 x 4 = 12', '3 x 5 = 15', # '3 x 6 = 18', '3 x 7 = 21', '3 x 8 = 24', '3 x 9 = 27', '3 x 10 = 30'] times_table(7)[9] # returns '7 x 10 = 70'
n can be any whole number, including 0 and negative numbers: times_table(-2)[2] is '-2 x 3 = -6'.
First solves only, ranked by stars and then time.