New to Python ?

I want to fill a list with a instanced class objects, then iterate through the list and call a method of each object with an index to the list. It’s easy in C# but I’m not getting it in Python can anyone help me out!!!

Say we have a list of strings (objects) and we want to call the strip method on all of them when we iterate through the list:

strlist = [... some list of strings ...]
for i in xrange(len(strlist)):
     strcopy = strlist[i].strip()

In short its list_object[index].method().

Note that you can iterate through each item of the list with:

strlist = [... some list of strings ...]
for s in strlist:
     strcopy = s.strip()

You can also iterate through and grab both the index and the item (not very useful for this example, though):

strlist = [.. some list of strings...]
for i,s in enumerate(strlist):
     strcopy = s.strip()