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 trialDan Morse
6,095 PointsSucceed without if statement?
Greetings! Does anyone know if there's a way to accomplish the fourth step, just using slicing? I was able to do it with len() and an if statement, but not with only slicing... Thoughts?
Thanks all!!!
2 Answers
Adrian Buenache
Python Web Development Techdegree Graduate 18,696 PointsOne approach could be to get first all even index numbers and then reverse that list, this way:
def reverse_even(iterable):
return iterable[::2][::-1]
I hope this helps you,
Dan Morse
6,095 PointsHey Adrian, that's super helpful! Thanks! I had no idea you could stack operations that way! Nice! Thanks again! ✌🏼
Adrian Buenache
Python Web Development Techdegree Graduate 18,696 PointsYou're wellcome! I've you ever need heelp, just ask. Oh, and cheers on your path to Techdegree! ;)