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
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 =='