Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions