View the step-by-step solution to:


Please define this function to do the following:

extract_layer(image, color)


It extracts a single color out of the RGB values of the color image and returns this layer as

a grayscale image. Input image should not be altered in any way.

Parameters: image (3D list of int) is the color image, color (string) is either 'red' or 'green' or


Return value: A 2D list of int


extract_layer([ [[1,0,4], [8,0,9],[3,1,3]],

[[7,4,9], [4,5,9],[7,6,0]],

[[0,0,6], [2,8,3],[5,4,3]] ], 'red') → [[1,8,3], [7,4,7], [0,2,5]]


 You are not allowed to import anything.

 You are not allowed to use recursion, classes, exceptions, and list comprehensions

 From the built-in functions, you are allowed to use: range(), len(), sorted(), int(), sum()

 From list methods, you are allowed to use:

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes