Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using None to index all elements
"""
You have a function that takes an argument, this argument is the index of the last element you want to show from an
array. At some point you want found out that you want to use this function but grab all elements. Just pass None.
"""
def some_function(last_idx):
print(some_arr[:last_idx])
some_arr = range(100)
last_idx = 5
some_function(last_idx)
last_idx = None
some_function(last_idx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment