I need to make a slice with the number 74 from the list using indexes (this is the condition of my assignment). But I don't understand what I need to write to get it. Please help.
This is my list:
L = [[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],
[[21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]],
[[41, 42, 43, 44, 45], [46, [47, 48], 49, 50], [51, 52, 53, 54, 55], [56, 57, 58, 59, 60]],
[61, 62, 63, [64, 65, 66, 67, 68, 69, 70, 71], 72, 73, 74, [75, [76, 77, 78], 79], 80],
[81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]
And if I write L[3][6]
, I get 74.
But by writing L[3[6]::]
, I get an error, even though I need a slice starting with the number with that index.
I need to get something like this:
[[74, [75, [76, 77, 78], 79], 80], [81, 82, 83, 84, 85, 86,
87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]
As @matszwecja says, L[3][6:]
gives you the part of the first sub-list you want, and L[4:]
is the rest of the original list; combine them to get the result you want.