Skip to content

Instantly share code, notes, and snippets.

@RaMSFT
Created October 21, 2022 12:19
Show Gist options
  • Save RaMSFT/815856a62ff2715ac325e4a4d42f1d1d to your computer and use it in GitHub Desktop.
Save RaMSFT/815856a62ff2715ac325e4a4d42f1d1d to your computer and use it in GitHub Desktop.
def find_index(input_list, search_str):
for val in range(0, len(input_list)):
if input_list[val] == search_str:
return f"index of {search_str} is {val}"
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