0

Please help with this.. using range.Generate the list 'A1' having numbers from 100 to 1 in decreasing order, which are also mult

Please help with this.. using range.Generate the list 'A1' having numbers from 100 to 1 in decreasing order, which are also multiple of 25. print 'A1'

6th Mar 2018, 11:18 AM
Sashank Reddy
Sashank Reddy - avatar
3 Answers
+ 3
A1 = {100, 75, 50, 25} print(A1) @Manorama is completely right, so there is nothing more to add
6th Mar 2018, 11:47 AM
J.G.
J.G. - avatar
6th Mar 2018, 11:32 AM
Manorama
Manorama - avatar
+ 1
Let me take a slightly different approach to Manorama: A1 = reversed(filter(lambda x: not x % 25, (_ for _ in range(1,101) ) ) ) The result obtained is an iterator which is more memory-efficient if you mind the difference. However, you can't get the items in A1 like what you did with list. You can get it through for loop or next function: for item in A1: print(item) or next(A1) Second argument in filter function is a generator comprehension, which is more memory-efficient.
6th Mar 2018, 12:21 PM
Andy Tan
Andy Tan - avatar