sort in Python

 Question:-

What is a large to small sort in Python?

sort in Python

sorting in python is quite easy in comparison to other programming languages.

it can be done in just one line in Python by using sort() method so firstly we should look at the syntax of it before using it and after that an example of it.

Let’s see-

Syntax:- list.sort(reverse=True|False, key=myFunc)

Example :-

  1. li=[1,4,5,6,5,8,669,52,255,8] 
  2. li.sort(reverse=True) 
  3. print(li)

Comments

Popular posts from this blog

Proassignmenthelp index 27

HackerRank Question: Print Function

Programmingshark index 18