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]
plz help me with this
how can i do it using map()??

Recommended Answers

All 2 Replies

Have a look at the range(start, stop[, step]) function (Click Here ) from python. Also, you can use it to generate reverse lists:
Resource - click me

Regarding your usage of the map(function, iterable) function: it applies a function to the iterable agrument, so you'll need some elements on which to apply the function.

Since you're using Python, you can introduce also a lambda function. For example (pseudo-code):

# map definition - map (function, iterable)

function input (number, multiplier) 
    iterable := reverse_range (multiplier, 0)
    l := list_of ( map ( lambda mult: number * mult, iterable) )
    return l

But again, if it's not mandatory to use the map function, you can easily generate this using only the range function (hint - make use of the optional step argument, which can be also negative).

That question was already asked here with more than enough hints to solve the problem.

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.