Maintaining order


Use the .index(item) function to find the index of "duck". Assign that result to a variable called duck_index.
Then .insert(index, item) the string "cobra" at that index.

Oops, try again. It looks like "cobra" is not at the correct location (index 4).

What is wrong here? All look fine with me...
Can someone spot out my mistake please?
Thank you in advance.

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

# Your code here!
animals.insert(duck_index, "Cobra")

print animals # Observe what prints after the insert operation


the "Cobra" on line 4 needs to be lower case "cobra"


Aahhhh, can't believe that I didn't notice that.
Many thanks for your help.


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