'Maintaining Order' says cobra is in the wrong place


#1

animals = ["aardvark", "badger", "duck", "emu", "fennec fox"]

duck_index = animals.index("duck")

animals.insert(duck_index,'Cobra')

print animals

This puts cobra before duck. Error message says Cobra's in the wrong spot. I've tried using numbers to put cobra everywhere. What's wrong with this code?


#2

cobra should have a lowercase c


#3

It works! I put a lowercase and it works.I usually hate not capitalizing but for this i had to


#6

animals = ["aardvark", "badger", "duck", "emu", "fennec fox"]
duck_index = animals.index["duck"]

# Use index() to find "duck"

animals.insert[duck_index, 'cobra']

print animals
what am i doing wrong can you tell me
???


#7

both index() and insert() are method so they require parentheses, not square brackets


#8

thanks man,it works.i didn't see that


#9