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 trial

Python Python Basics (2015) Python Data Types Specific Index value

I could not solve it var_one = ['a', 'b', 'c', 'd', 'e', 't'] var_two = ['e'.index(-2)]

need some help with this last step

thank you var_one = ['a', 'b', 'c', 'd', 'e', 't'] var_two = ['e'.index(-2)]

index.py
var_one = ['a', 'b', 'c', 'd', 'e', 't']
var_two = ['e'.index(-2)]

3 Answers

Joel Price
Joel Price
13,711 Points

Heyo,

So this is asking you to create basically another list name var_two in which 'e' is at position -2. Which means 'e' should be on the second slot going from right to left. Something like this should do it:

var_one = ['a', 'b', 'c', 'd', 'e', 't']
var_two = ['f', 'e', 'g']

Give it a shot and see how it works for ya.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi Joel Price! I took the liberty of making your comment an answer. This has a couple of benefits. First, it marks the question as answered on the forums. Secondly, it allows for voting on your answer and possible selection of "Best Answer". Thanks for helping out in the Community! :sparkles:

thanks you

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You actually did sort of solve it already. It wants a string or a list such as the next to last element/character is an "e". But you did that in your original list. Simply copying the list in the first one and assigning it to var_two would work. But since you already have it in place, you can do something even much simpler.

var_two = var_one

Hope this helps! :sparkles:

Thanks,

I thought that too, but it took me a while to understand it, English isn't my first language

Thanks a lot Jennifer

Joel Price
Joel Price
13,711 Points

Jennifer Nordell Thank you! Didn't realize that a comment wasn't the same as an answer!