Skip to content

Instantly share code, notes, and snippets.

@RaMSFT
Created October 21, 2022 12:23
Show Gist options
  • Save RaMSFT/e00831b1553256da58a39763cd2d7a65 to your computer and use it in GitHub Desktop.
Save RaMSFT/e00831b1553256da58a39763cd2d7a65 to your computer and use it in GitHub Desktop.
def find_element_with_index(input_list, index_value):
try:
return f"Element value: {input_list[index_value]} at the index: {index_value}"
except:
return f"no element exists at the index {index_value}"
print(find_element_with_index(["hi", "edabit", "fgh", "abc"], 1))
print(find_element_with_index(["Red", "blue", "Blue", "Green"], 2))
print(find_element_with_index(["a", "g", "y", "d"], 10))
print(find_element_with_index(["Pineapple", "Orange", "Grape", "Apple"], 3))
print(find_element_with_index(["Pineapple", "Orange", "Grape", "Apple"], 100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment