< Back

Post Lab 23

Post labs are to be done individually. Sharing files between students is not allowed. Doing so is an Academic Integrity violation, and will be treated as such.


Because lists are mutable it is possible to write functions that manipulate lists without returning anything. To demonstrate your understanding of mutable lists, write a function that removes objects from a list.

Details

Write a function called remove_all(a_list, item). The function should modify a_list to remove all items in the list that are equal to item without changing the order of the other items. Note that the function should not return anything. Be careful iterating over a list while removing from it.

Make sure your program handles all necessary cases gracefully. What additional test cases should you check?

Example

>>> my_list = [1, 2, 3, 2, 1]
>>> remove_all(my_list, 2)
>>> print(my_list)
>>> [1, 3, 1]

Submission

Submissions for post labs are to be done via the inquire system. Go to http://inquire.roanoke.edu/ You should see a section for post labs. Submit your .py file to the appropriate post lab location.

Post labs are to be done individually. Sharing files between students is not allowed. Doing so is an Academic Integrity violation, and will be treated as such.