Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Functional Python Functional Workhorses Map

David Hernandez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
David Hernandez
Python Development Techdegree Graduate 12,180 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.

maps.py
from copy import copy


backwards = [
    'tac',
    'esuoheerT',
    'htenneK',
    [5, 4, 3, 2, 1],
]


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

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 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!