This is how the scenario looks: I am try to get the max element from an list, based on another element which essentially represents the index amongst the elements i need to search. The length of foo can change. but the length of test will not change.
>>> test = [1,2,3,4,5,6,7,8] >>> foo = [1,4] >>> print max(test[foo[1]]) This works..
But, when I am trying to do
>>> print max(test[foo]) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: list indices must be integers, not list Is there some other way, or should I refer to another module? If yes, could you please suggest it to me.
foo[1]to4, then returnstest[4], which is5, and then givesmax(5), which is5.foorepresents a range, but then you say that the length offoocan change? What does that mean?fooas an index. Am i clearer now?