slicing behaviour question of a list of lists
Posted
by Lex
on Stack Overflow
See other posts from Stack Overflow
or by Lex
Published on 2010-03-18T00:49:22Z
Indexed on
2010/03/18
0:51 UTC
Read the original article
Hit count: 477
I got a function like
def f():
...
...
return [list1, list2]
this returns a list of lists
[[list1.item1,list1.item2,...],[list2.item1,list2.item2,...]]
now when I do the following:
for i in range(0,2):print f()[i][0:10]
it works and print the lists sliced
but if i do
print f()[0:2][0:10]
then it prints the lists ignoring the [0:10] slicing.
Is there any way to make the second form work or do I have to loop every time to get the desired result?
© Stack Overflow or respective owner