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 trialGreg Maddox
1,471 PointsI just cant get this one!
I don't understand how this negative even slicing works. It seems like it should, but it keeps starting at the second element, not the [0]
def first_4(array):
return array[:4]
def first_and_last_4(array):
second_list = array[:4]
second_list.extend(array[-4:])
return second_list
def odds(array):
return array[1::2]
def reverse_evens(array):
return array[::-2]
4 Answers
Steven Parker
231,236 PointsThere's a bit more to the last task. Consider that to return only the even indexed values, you would need to start at either the last or the second-to-last item depending on whether the list had an odd or even number of items in it.
So you'll either need to compute the starting position based on list size, or extract the even indexes first and then reverse them.
Greg Maddox
1,471 PointsThanks a lot! That was very helpfully, i was able to finish the challenge.
eg3
2,681 Pointsthis worked for me...
def sillycase(i):
half = int(round(len(i)/2))
low = i[:half].lower()
upp = i[half:].upper()
return (low + upp)
Steven Parker
231,236 PointsI believe that's for a different challenge!
eg3
2,681 Pointsyou're right ;-) ....I had maybe too much screens, silly me