I´m trying to do this following exercise:
- 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.
So the code I wrote is this:
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
According to the print duck_index, this one is 2. The instruction is to insert "cobra" at that index, but the console tells "Oops, try again. Make sure to pass duck_index as the first argument in insert()". It is someting wrong in my code? Could you help me please?
Thank you in advance