The correct answer is:
C. [3, 2, 1]
Explanation:
The code iterates over each element v in my_list_1 and inserts v at the beginning (index 0) of my_list2. This results in reversing the order of the elements from my_list_1 in my_list2. Here is the step-by-step process:
v = 1 -> my_list2.insert(0, 1) -> my_list2 becomes [1]
v = 2 -> my_list2.insert(0, 2) -> my_list2 becomes [2, 1]
v = 3 -> my_list2.insert(0, 3) -> my_list2 becomes [3, 2, 1]
Therefore, the final output of print(my_list2) is [3, 2, 1].
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, 20 hours agochristostz03
4 months, 1 week ago