Question: Python Use loop Write a function find(elem, seq) that takes as inputs an element elem and a sequence seq, and that uses a loop to

Python
Use loop  Python Use loop Write a function find(elem, seq) that takes as
inputs an element elem and a sequence seq, and that uses a

Write a function find(elem, seq) that takes as inputs an element elem and a sequence seq, and that uses a loop to find and return the index of the first occurrence of elem in seq. The sequence seq can be either a list or a string. If seq is a string, elem will be a single-character string if seq is a list, elem can be any value. Don't forget that the index of the first element in a sequence is 0. Important notes: - If elem is not an element of seq, the function should return -1 - You may not use the in operator in this function to test for the presence of elem in seq. However, you are welcome to use in as part of the header of a for loop. In addition, the only built-in functions that you may use are len and range

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!