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