Created
October 21, 2022 12:21
-
-
Save RaMSFT/6daf213114eb8c6763e597421f78f290 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_index(input_list, search_str): | |
try: | |
val = input_list.index(search_str) | |
return f"index of {search_str} is {val}" | |
except: | |
return f"index of {search_str} is not found" | |
print(find_index(["hi", "edabit", "fgh", "abc"], 'fgh')) | |
print(find_index(["Red", "blue", "Blue", "Green"], 'blue')) | |
print(find_index(["a", "g", "y", "d"], 'd')) | |
print(find_index(["Pineapple", "Orange", "Grape", "Apple"], "Pineapple")) | |
print(find_index(["Pineapple", "Orange", "Grape", "Apple"], "pp")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment