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

Mesrop Janoyan
Mesrop Janoyan
10,165 Points

Why doesn't my code work on Treehouse Challenges, but works as intended in my terminal running python3?

I ran the code "return [thing[::-1] for thing in things]" in my terminal and it returned what I expected. Meanwhile, I get "Bummer! reverse didn't accept an argument" when I use the same code in Treehouse.

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

def reverse(things):
    return [thing[::-1] for thing in things]

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

You are doing more than the challenge requests. It only wish to reverse the iterable passed as a parameter, not reverse each element in the iterable. This is sufficient for Task 1:

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

def reverse(things):
    return things[::-1]
Mesrop Janoyan
Mesrop Janoyan
10,165 Points

Yepp, that definitely fixed it. Thank you for such a quick reply!