7. Maintaining Order


Hi, i’m on this topic and i just don’t understand what in the world i’ve done wrong.

animals = ["aardvark", "badger", "duck", "emu", "fennec fox"]
duck_index = animals.index("duck") # Use index() to find "duck"
print duck_index
# Your code here!
animals.insert(2, "cobra")

print animals # Observe what prints after the insert operation

The script shows
[‘aardvark’, ‘badger’, ‘cobra’, ‘duck’, ‘emu’, ‘fennec fox’]

But i keep getting a message saying Make sure to pass duck_index as the first argument in insert().
I have no clue what its trying to tell me.
If i could get some help that would be appreciated :slight_smile:


you should use duck_index variable to insert the cobra, not a fixed number. This makes your code more robust and flexible


Wow, thank you for the fast response.
i feel so stupid for not realising earlier now, but thank you :slight_smile:


You’re welcome

Don’t feel stupid about it, you aren’t the first and very likely not the last person to make that mistake


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.