Lists and dictionaries assignment


I need help with this code:

animals = ["aardvark", "badger", "duck", "emu", "fennec fox"]
duck_index = animals.index("duck") # Use index() to find "duck"

Your code here!

animals.insert(2, "cobra")

print animals # Observe what prints after the insert operation

I have no errors in the shell and I believe it is doing what I want it to do but the codecademy program tells me to try again because I haven't passed the duck_index as the first argument. do you know what this means?? thanks a lot!


It means exactly what it says, you need to pass "duck_index" instead of 2. I know it sounds a little confusing and I can totally see why you put 2, but in this case it needs to be "duck_index", which happens to equal 2.


animals.insert(duck_index, "cobra")


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