26.2k views
2 votes
 myLIst = [1, 2, 45, 66, 77, 88]

White the line of code which will sort the elements in myList.

 myLIst = [1, 2, 45, 66, 77, 88] White the line of code which will sort the elements-example-1
User Charla
by
8.3k points

1 Answer

2 votes

Answer:

myList.sort() ->sort the elements in ascending order

myList.sort(reverse=True) -> sort the elements in descending order

Step-by-step explanation:

Hi,

To sort the elements of a list, we can use the sort() function in Python. This function can optionally receive the "reverse" argument which specifies whether the sorting is done in descending order. If it is called without this argument, the sorting is by default in ascending order. If the "reverse=True" argument is specified, then the sorting will be done in descending order.

The line of code is:

myList.sort() -> sort the elements in ascending order

myList.sort(reverse=True) -> sort the elements in descending order

Good luck!

User WavyGravy
by
7.3k points