← Back to challenges

Find the Index

PythonMediumarraysstringslanguage_fundamentalsloops

Instructions

Create a function that takes a list and a string as arguments and returns the index of the string.

Examples

find_index(["hi", "innokodakademija", "fgh", "abc"], "fgh") ➞ 2

find_index(["Red", "blue", "Blue", "Green"], "blue") ➞ 1

find_index(["a", "g", "y", "d"], "d") ➞ 3

find_index(["Pineapple", "Orange", "Grape", "Apple"], "Pineapple") ➞ 0

Notes

  • The variable for list is lst, not 1st.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Assign Person to Occupation