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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started