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.
Sam_sgv
3 weeks, 4 days agoyagebin
1 month, 1 week agohovnival
1 month, 1 week agoNfyughguygjhg
2 months agorcptryk
2 months, 2 weeks agomldprasad
2 months, 3 weeks agoVano1
3 months, 1 week agoscriptnone
3 months, 2 weeks agoSujPractise
4 months, 1 week agochristostz03
5 months, 2 weeks agoBiju1
5 months, 3 weeks agoBiju1
5 months, 3 weeks ago