I am stuck on a question which asks:
Write a function print_matching_indexes(items, target)
that prints the indexes of all the occurrences of the target
in the list
items. We are using for loops for iterating over lists
I have written:
def print_matching_indexes(items, target):
"""Prints the indexes of all (target) in the list (items)"""
for i in items:
print (items.index)
But I am receiving the message:
<built-in method index of list object at 0x7fc8103caa00>
<built-in method index of list object at 0x7fc8103caa00>
<built-in method index of list object at 0x7fc8103caa00>
If it works the following test code should result in:
pets = ['dog', 'cat', 'fish', 'cat', 'dog', 'iguana']
print_matching_indexes(pets, 'cat')
Result
1
3
Any pointers of where I'm going wrong?