Question: Using Python: write a function that takes two arguments: (1) a target item to find, and (2) a list. Your function should return the index

Using Python: write a function that takes two arguments: (1) a target item to find, and (2) a list. Your function should return the index (offset from 0) of the last occurrence of the target item or None if the target is not found. E.g. the last occurrence of 33 is at offset 3 in the list [ 42, 33, 21, 33 ] because 42 is offset 0, the first 33 is at offset 1, 21 is offset 2, and the last 33 is offset 3.

Use unittest to test your function with several different target values and lists.

Next, test your function with a character as the target, and a string as the list, e.g. find('p', 'apple'). What should happen?

Be sure to use unittest to demonstrate that your code works properly.

Using Python: write a function that takes two arguments: (1) a target

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!