Simple question about Python lists

Eric eric.shain at gmail.com
Tue Nov 11 14:47:53 EST 2008


I'm learning Python (while coming from MATLAB). One question I have is
that if I have a list with say 8 elements, and I want just a few of
them how do I select them out. In MATLAB, if I just want the first,
fifth and eighth element I might do something like this:

b = a([1 5 8]);

I can't seem to figure out a similar Python construct for selecting
specific indices. Any suggestions?

Thanks,

Eric



More information about the Python-list mailing list