Please Help With Lesson 7


#1

Hello,

  • The question of 7 is:
    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.

  • The code you work with is:
    animals = ["aardvark", "badger", "duck", "emu", "fennec fox"]
    duck_index = # Use index() to find "duck"

  • Now, my solution:
    duck_index = animals.index("duck")
    animals.insert(duck_index, "cobra")

  • The error I get:
    Oops, try again. Did you forget to assign a value to duck_index?

Why do I get this error?

Thanks!


#2

FORGET THIS THREAD!

They already created duck_index.
I didn't notice that so I created duck_index AGAIN!

SOLVED!