I know that I can use something like string[3:4] to get a substring in Python, but what does the 3 mean in somesequence[::3]?
I know that I can use something like string[3:4] to get a substring in Python, but what does the 3 mean in somesequence[::3]?
Did I miss or nobody mentioned reversing with [::-1] here?
# Operating System List
systems = ['Windows', 'macOS', 'Linux']
print('Original List:', systems)
# Reversing a list
#Syntax: reversed_list = systems[start:stop:step]
reversed_list = systems[::-1]
# updated list
print('Updated List:', reversed_list)
source: https://www.programiz.com/python-programming/methods/list/reverse
remember that the foundations is what a[start:end:step] means. From there you can get a[1::2] get every odd index, a[::2] get every even, a[2::2] get every even starting at 2, a[2:4:2] get every even starting at 2 and ending at 4. Inspired by https://stackoverflow.com/a/3453102/1601580