CS5NM in class exercise ex16, 12/01

Write a Python function called toMod5() that consumes a list of integers, and produces a list of integers. The list that is returned should be the same as in the list passed in, except that each integer is replaced with that same integer, mod 5.

For example, if we pass in [3,7,15,2,4,10], the function should return [3,2,0,2,4,0]

For an empty list, you should return an empty list.

Here is one test case, written using the function new_check_expect() that we went over in lecture on Monday 11/24.

new_check_expect("toMod5( [3,7,15,2,4,10])", [3,2,0,2,4,0])

Your job is to do two things:

  1. Write two more test cases (other than the one listed above), using the new_check_expect() function.\
  2. Finish the function definition below so that the function operates properly, and passes the test cases.
# toMod5
# consumes: list of integers
# produces: same list of integers, but each integer in the list replaced with that integer, mod 5
def toMod5(lst):
  # Fill in the rest of the code ...