Wednesday, 28 October 2020

Sort in reverse order in Python

 

Hi,

Here one list is loaded with cubes. One element is edited intentionally. 


a=[]

for i in range(10):

a.append(i**3)

a[4]=10

print(a)

a.sort(reverse=True)

print(a)

No comments:

Post a Comment