Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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!