Skip to content

Instantly share code, notes, and snippets.

@knapply
Last active November 5, 2018 18:50
Show Gist options
  • Save knapply/65c586e6003362f1aba5bcad0df8f4f6 to your computer and use it in GitHub Desktop.
Save knapply/65c586e6003362f1aba5bcad0df8f4f6 to your computer and use it in GitHub Desktop.
Python: Length from scratch
def py_length(x):
out = 0
for i in x:
out += 1
return out
py_generator = range(1, 21)
result = py_length(py_generator)
print(result)
#> 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment