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 trialDavid Hernandez
Python Development Techdegree Graduate 12,180 Pointsunable 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 = [
'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
Treehouse Moderator 28,722 PointsI 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!
David Hernandez
Python Development Techdegree Graduate 12,180 PointsDavid Hernandez
Python Development Techdegree Graduate 12,180 PointsThank you Jeff. I caught that I was misreading it after I took a break. You helped validate that too. Much appreciated.