Lets say I have a list:
listOfStuff =([a,b], [c,d], [e,f], [f,g])
What I want to do is to iterate through the middle 2 components in a way similar to the following code:
for item in listOfStuff(range(2,3))
print item
The end result should be as below:
[c,d]
[e,f]
This code currently does not work, but I hope you can understand what I am trying to do.
You have to iterate over a slice of your tuple. The
1is the first element you need and3(actually 2+1) is the first element you don’t need.Elements in a list are numerated from 0:
[1:3]takes elements 1 and 2.