[Tutor] selecting data from a list

Mark Lawrence breamoreboy at yahoo.co.uk
Sun Jan 18 18:42:38 CET 2015

On 18/01/2015 00:49, Colin Ross wrote:
> Hi all,
> I am attempting to isolate a certain subset of data from the list "a" and
> then turn it into any array. To do so, I have written the following code:
> import numpy as np
> a = [0,1,2,3,4,5,6,7,8,9,10]
> b = [10,20,30,40,50,60,70,80,90,100,110]
> for a in range(len(a)):

As others have already offered the usual sound advice I'll just say that 
using the above type of construct is usually wrong in Python.  A useful 
tip is to make your container names plural, then process the singular 
name so lets have:-

cars = ['Ford, 'Vauxhall', 'Land Rover', 'Jaguar']
for car in cars:

My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

More information about the Tutor mailing list