I’m working with list and list of list. I need to be able to address the data from both ways (right to left and left to right). This is needed when you have a list of lists AND need to address the last ‘sub’ list of the list of lists. Just groups of data. But we need to address the complete last dataset (sub list). Even if it is the first data sub list or the 50th. As it is now we lose data.
data = [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 'test 3b',
'Lumpy', 0, 0, 45, 18, 24, 19, 9]
a = -1
b = -21
# Example: data[b:a]
print('this should be 0 ', data[0])
print('this should be 9 ', data[20])
print('this should be 9 ', data[-1])
print('this should be 0 ', data[-21])
print('this should be 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "test 3b", '
'"Lumpy", 0, 0, 45, 18, 24, 19, 9 ', data[-21:-1]) # missing 9 at end
OUTPUT:
this should be 0 0
this should be 9 9
this should be 9 9
this should be 0 0
this should be 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "test 3b", "Lumpy", 0, 0, 45, 18, 24, 19, 9 output [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 'test 3b', 'Lumpy', 0, 0, 45, 18, 24, 19]
It drops data. I need help understanding this.
Thanks