Well done!
You have completed Sorting and Reversing Lists Quiz!
Quiz Question 1 of 5
Consider a scenario where the list contains dynamic and continuously updating data, and you need to add a new element to the end of the list but ensure that it remains the last element even as other operations are performed. Which approach would you choose and why?
Choose the correct answer below:
-
A
Use a loop to remove any element from the end before adding the new one with
append()
. -
B
Use
append()
as it automatically ensures that the new element is added to the end of the list. -
C
Use
append()
followed by apop()
to remove any potential duplicates. -
D
Continuously check the length of the list and insert the element at the index corresponding to the last position.