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!

You can do this with list comprehension. A hint

x=3
print range(x, 0, -1)

You can do this with list comprehension. A hint

x=3
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]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.