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 trialSC3 Rocks
33,474 PointsSpecific Index Challenge - Task 2 of 2
I'm having trouble with this task - I would appreciate some assistance, please and thank you:
Great! One more thing to practice. Make a new variable, var2, with "e" at index -2. Remember, negative indexes start at the right side of the iterable.
This is what I tried already:
var1 = ["e","a", "b", "c", "d", "t"]
var2 = ["e", "a", "b", "c", "d", "t"]
3 Answers
Chris Seale
24,718 PointsYes, simply count 2 backwards on the index from the end and place the "e" there. -1 would be the "t". -2 then, goes right before it.
markmneimneh
14,132 PointsHi
Try this
var1 = ["e","a", "b", "c", "d", "t"]
var2 = ["e", "a", "b", "c", "e", "t"]
print(var2[-2])
SC3 Rocks
33,474 PointsI passed the challenge - Thank you both for your help... P :)