Last active
November 5, 2018 18:50
-
-
Save knapply/65c586e6003362f1aba5bcad0df8f4f6 to your computer and use it in GitHub Desktop.
Python: Length from scratch
This file contains 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 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