Re: [Tutor] indexing question

2007-09-26 Thread Kent Johnson
Emad Nawfal wrote: > Hi Tutors, > Is there a way to get the index of every occurence of a certain element > in a list. listname.index(element) gives me the index of the first > occurence. For example: > > >>> t = 'we are we are we we we'.split() > Now I want the index of each 'we' in t. I want

[Tutor] indexing question

2007-09-26 Thread Emad Nawfal
Hi Tutors, Is there a way to get the index of every occurence of a certain element in a list. listname.index(element) gives me the index of the first occurence. For example: >>> t = 'we are we are we we we'.split() >>> t ['we', 'are', 'we', 'are', 'we', 'we', 'we'] >>> for word in t: if word =='