(Oct-11-2019, 03:54 AM)doug2019 Wrote: the problem is that list must always have 10 elements and "a" and "b" will be input by the user
Will this meet your needs?
a = 1 b = 5 mlist= [0]*(a - 1) + [a * (b - x) for x in range(a, b+1)] + [0]*(10 - b) print(mlist)
Output:[4, 3, 2, 1, 0, 0, 0, 0, 0, 0]
If you need to have the calculated values in ascending order, you could try the following:
a = 1 b = 5 mlist= [0]*(a - 1) + [a * (b - x) for x in range(b, a-1, -1)] + [0]*(10 - b) print(mlist)
Output:[0, 1, 2, 3, 4, 0, 0, 0, 0, 0]
A.D.Tejpal