DAY 10 of PYTHON top 100 questions : from Basic to Advanced !!

DAY 10 of PYTHON top 100 questions : from Basic to Advanced !!

Write a Python program to sort a given array in ascending order :

a=[2,4,8,1,4,6]
a.sort()
print("The ascending order ",a)

Output :

The ascending order  [1, 2, 4, 4, 6, 8]

The sort() method in Python can be used to sort a list of numbers in ascending order. In the example, the list a is sorted using sort() and the sorted list is then printed to the console using the print() function.

The sort() method has sorted the list in ascending order, from smallest to largest.


If you are a beginner and want to know more about Python programming, you can read my Basics of Python blogs (From part 1 to part 15).


HAPPY LEARNING !!!