Python Programming - Data Types - Discussion

Discussion Forum : Data Types - General Questions (Q.No. 61)
61.
What will be the output of the following code snippet?
my_list = [4, 2, 7, 1, 9]
result = sorted(my_list)
print(result)
[1, 2, 4, 7, 9]
[9, 7, 4, 2, 1]
True
False
Answer: Option
Explanation:
The sorted() function in Python returns a new sorted list from the elements of the given iterable, in this case, the list my_list. So, the elements of my_list will be sorted in ascending order, and the sorted list [1, 2, 4, 7, 9] will be printed.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.