Informatics Practices

What will be the output of the following statement?

list1 = [12, 32, 65, 26, 80, 10]
sorted(list1)
print(list1)

Python List Manipulation

6 Likes

Answer

[12, 32, 65, 26, 80, 10]

Working

In the given code, list1 is initialized as [12, 32, 65, 26, 80, 10]. The sorted(list1) function is called, which creates and returns a new list with the elements of list1 sorted in ascending order, but it does not modify the original list1. Since the sorted result is not stored or printed, the next line print(list1) outputs the original unsorted list [12, 32, 65, 26, 80, 10].

Answered By

4 Likes


Related Questions