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 trialTim Enders
11,288 PointsStuck on Task 2
So, this doesn't make much sense. I have completed step 1, so I would assume the definition of reverse() is perfectly fine. Then the map() call applies reverse() to each item in backwards, 'tac', 'esuoheerT', etc. Which is what I have been asked to do. Reverse each item in backwards.
However I get an error that says not all items were reversed correctly.
I have tried taking off the list() calls, but that always throws a new error.
backwards = [
'tac',
'esuoheerT',
'htenneK',
[5, 4, 3, 2, 1],
]
def reverse(item):
return list(reversed(item))
forwards = list(map(reverse, backwards))
2 Answers
MUZ141095 Kelvin Chawora
9,348 PointsThere is no need for calling list()
I'm pretty sure this should work ;)
backwards = [
'tac',
'esuoheerT',
'htenneK',
[5, 4, 3, 2, 1],
]
def reverse(item):
return item[::-1]
forwards = map(reverse, backwards)
akak
29,446 PointsYou are very close:
backwards = [
'tac',
'esuoheerT',
'htenneK',
[5, 4, 3, 2, 1],
]
def reverse(item):
return item[::-1]
forwards = list(map(reverse, backwards))
Tim Enders
11,288 PointsThanks. Now I see that I mistyped when moving from workspace to challenge (Anyone know why that copy/paste doesn't work?).
Tim Enders
11,288 PointsTim Enders
11,288 PointsSo worked on this in workspaces... This code returns the right answer for Task 2, but does not pass Task 1...
backwards = [ 'tac', 'esuoheerT', 'htenneK', [5, 4, 3, 2, 1], ]
def reverse(item): return list[::-1]
forwards = list(map(reverse, backwards))