To achieve the expected output [1, 2, 4, 7] from the list [2, 7, 1, 4], you should use the list.sort() method, which sorts the list in place.
Here is the complete code snippet:
Copy
list = [2, 7, 1, 4]
list.sort() # This sorts the list in place
print(list)
So, the correct line to use is:
C. list.sort()
C is correct because the output expectation must come from print(list) not from the print(sorted(list)). you have to write comment before the print which is list.sort() or you have to write list=sorted(list) which is not option
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
hovnival
2 days, 21 hours agoNfyughguygjhg
3 weeks agorcptryk
1 month, 1 week agomldprasad
1 month, 1 week agoVano1
1 month, 4 weeks agoscriptnone
2 months, 1 week agoSujPractise
3 months agochristostz03
4 months, 1 week agoBiju1
4 months, 1 week agoBiju1
4 months, 1 week ago