How to access elemenst in a list of lists?
Antonio CHESSA
4aedc00f81024 at poster.grepler.com
Mon May 9 04:25:11 EDT 2011
>Just learning python.
>I can see that I can address an individual element of a list of lists
>by
>doing something like:
>row = list[5]
>element = row[3]
>
>But is there a way to directly address an entry in a single statement?
>Thanks for any help.
>Regards
>Chris Roy-Smith
suppose you have a list like this:
apple = [["a","b","c"],[1,2,3,4,5,6],["antony","max","sandra","sebastian"]]
apple[0] = ["a","b","c"]
apple[1] = [1,2,3,4,5,6]
apple[2] = ["antony","max","sandra","sebastian"]
apple[0][1] = "b"
apple[2][3] = "sebastian"
to view all videos in a loop so you can set:
for i in range(len(apple)):
print apple[i]
for j in range (len(apple[i])):
print apple[i][j]
in your monitor when you do run this little program, you will see:
["a","b","c"]
a
b
c
[1,2,3,4,5,6]
1
2
3
4
5
6
["antony","max","sandra","sebastian"]
antony
max
sandra
sebastian
Bay
vonkes
----------------------------
http://grepler.com groups
More information about the Python-list
mailing list