We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
It's called list slicing and returns a slice of the original list. The notation is [start_index:end_index:step]. Step defaults to 1. Both start_index and end_index can be omited, which will make them default to beggining and end of a list. Can be used with strings as well. You can use negative values to count from the end of a list (-1), as well as negative step to reverse the list.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Runner-Up Score!
You are viewing a single comment's thread. Return to all comments →
It's called list slicing and returns a slice of the original list. The notation is [start_index:end_index:step]. Step defaults to 1. Both start_index and end_index can be omited, which will make them default to beggining and end of a list. Can be used with strings as well. You can use negative values to count from the end of a list (-1), as well as negative step to reverse the list.