Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Functional Python Functional Workhorses Map

David Hernandez
.a{fill-rule:evenodd;}techdegree seal-36
David Hernandez
Python Development Techdegree Graduate 10,707 Points

unable to create a function that reverses

I keep getting an error that says reverse didn't accept an argument, however, if I run it locally it works just fine.

from copy import copy

backwards = [
    [5, 4, 3, 2, 1],

def reverse(items):
    items = copy(items)
    return [item[::-1] for item in items]

1 Answer

Jeff Muday
Jeff Muday
Treehouse Moderator 27,653 Points

I can see from your code you understood how to reverse an array. Good job!

It is a little simpler than you expected.

def reverse(items)
    return items[::-1]

Now, for the second part of the Challenge, you are going to use reverse as a reference to the function in Part 1. And map() to assign a new variable forwards

forwards = map(reverse, backwards)

The wording is a little bit awkward, but you get the gist of it!