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!
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
Error in Setep 4
Hi, I have a question. Why def reverse_evens(let): return (let[::-2])
return Error? If this is a bug or a future.
Best reqards Lukas
def first_4 (let): return (let[0:4]) def first_and_last_4 (let): return (let[:4] + let[-4:]) def odds (let): return (let[1:3]) def reverse_evens(let): return (let[::-2])
I know that, but my question was why this function return error? def reverse_evens(let): return (let[::-2])
I tested it in local pycharm and I do not have this problem.
JongHo Kim8,313 Points
I believe I found out the issue. I had the same problem too, but then I realized that if the number of indexes was odd, counting backwards by two would return the values of the odd indexes. I chose to create a list of the even indexes and then reversed it to avoid this issue.
My solutions are in question_answers.py
Hope this helps!