Skip to content

Instantly share code, notes, and snippets.

@computer-tutor
Created April 25, 2020 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save computer-tutor/f976499a41fbfce125573415b0e1b307 to your computer and use it in GitHub Desktop.
Save computer-tutor/f976499a41fbfce125573415b0e1b307 to your computer and use it in GitHub Desktop.
def find_in_list(lst, v):
for i in range(len(lst)):
if lst[i] == v:
return i
break
return -1
l = [1, 2, 3, 4]
print(find_in_list(l, 3)) # 2
print(find_in_list(l, 5)) # -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment