Duck / Cobra Index help!


#1



https://www.codecademy.com/courses/python-beginner-en-pwmb1/1/4?curriculum_id=4f89dab3d788890003000096#


Oops, try again. Did you remember to use index() in your code


['aardvark', 'badger', 'cobra', 'duck', 'emu', 'fennec fox'] is what prints out but I'm still getting a "Error " message

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

duck_index = (2)    # Use index() to find "duck"

animals.insert(duck_index , "cobra")



print animals


#2

I figured it out ... forgot to print animals.index("ducks")

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

duck_index=(2)
print animals.index("duck")
animals.insert(duck_index, "cobra")

print animals


#3

It's actually supposed to be like this.

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

animals.insert(duck_index, "cobra")

print animals


#4

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