Error in indexing for list


Dear Sir,
Below code is for your coecademy course for maintaining order and this code suppose to find index for "duck" and insert new string "cobra".As per me below code are correct but still it gives me error i.e (Oops, try again. It looks like there may have been a problem with insert() or index(). Double check them!)


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

Your code here!


print animals # Observe what prints after the insert operation

My regards,


Dear Sir,
I just struck here my lesson is not going for next and all codes seems working fine . Can you check for me please so, that i can go through to next lesson. I am waiting for your usual support..

My regards,


By the way, do you speak Portuguese from Brazil?
It's because I'm seeing the item "naja" in Portuguese!
It is also to facilitate in my reply.


Dear Sir,
I am from Nepal and i have no idea on Portuguese... but this issue block to go through next lesson. So, sir can you please help to get out form this issue.



Here's how you should do your code.


animals.insert(duck_index, "item")


Woohhhh, Yes!! i got it thank boss. I just pass the just exact index value instead of putting index value of "duck".
Now i got this whole idea thank you boss. I really appreciate your help.

My regards,


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