Mantaining order - Help!


Please, help.

My code is:
"animals = ["aardvark", "badger", "duck", "emu", "fennec fox"]

duck_index = animals.index("duck")

animals.insert(duck_index, "corba")

print animals"

The mistake: " It looks like "cobra" is not at the correct location (index 4)."

Why it's not working?


Why is there a double-quote before animals? That's incorrect. animals is supposed to be a list, not a string.



Another quotation mark after animals. That's not needed.


There's no a double quote, I've just put it here to distinguish the code. Old habbit. So, there's no quote in my editor.

Look what I wrote:
duck_index = animals.index("duck")

animals.insert(duck_index, "corba")

So I defined duck_index and now the program knows it. And then I inserted "cobra" at that index.

Again, just for this forum. In the editor there's no quotation.


My apologies for not replying so quickly, my Wi-Fi was broken all day yesterday and partly today, so that had to get fixed.

You're doing great! There's only one thing you need to fix....

Look at "corba", it isn't spelled right :slight_smile:


Thank you, now it works


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