Hello everyone! I got this question in a book.. I thought of doing it using map() or using loops

return the first count multiples of number in desc order in a list.
e.g call with input (3,2) returns [6,3]
call with input(5,3) returns [15,10, 5]

but the hint along with the question says

Hint: one line of code, use a builtin function.

now i'm in doubt that how can we do it in 1 line and if we cn then what is that builtin function??
Another way i thought was taking the list by range function, which will give

[1,2] for first example then multiply the elements of list by 3 and then reverse it.. But the hint says something else! Please help!

4 Years
Discussion Span
Last Post by rrashkin

You can do this with list comprehension. A hint

print range(x, 0, -1)

But how do i multiply 3 with the list members as i'm not allowed to use loops??


Are you allowed to use list comprehension which is an implicit for loop?

[i*6 for i in xrange(3,0,-1)]
  [18, 12, 6]
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.