Slicing Beyond the List Size in Python


Safely slice lists without worrying about the range.

Source Code

my_list = [1, 2, 3]
print(my_list[:10])  # Returns the whole list, no error
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments