I have a list present with some elements stored . I want to apply ssome function on all elements of the list and want to sort the list into reverse order.Then I would like to convert the resulting list to set()
. But my code does not seem to work. Can somebody take a look and tell me what is wrong with my code. The last line is the output from print a. What is wrong with this code
B=[2,3,4,5,7,66,56,34,22,345, 22,3,5]
a=set(sorted([2*t for t in B], reverse=True))
print(a)
# output: {132, 68, 6, 4, 8, 10, 44, 14, 112, 690}
Now in other form , my code is :
sorted(set([2*t for t in B]), reverse=True)
which seems to work out fine and produce:
[690, 132, 112, 68, 44, 14, 10, 8, 6, 4]
can somebody tell the difference