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

what is wrong my answer ?

var2 = "e" var2.index['-e']

index.py
var1 = ["a", "b", "c", "d", "e", "t"] 
var2 = "e"
var2.index['-e']

7 Answers

Here is an example of what it is looking for:

var1 = "Shoutting"
var2 = "computer"

In task 1 it was wanting a word that had the letter 't' in index 5 and in task 2 it wanted a word/iterable with the letter 'e' in the -2 index which basically equals the second to the last letter from the end.

how do I write the code? please

My code is towards the top.

The negative index starts as at -1 at the end of the list or string, from there it moves to the left.

Using lists:

var2 = [0,1,2,"e",4]
vae2 = ["B","B","B","B","B","B","B","e","B"]

Using strings:

var2 = bbbeb
var2 = bbbbbbbbbbbbbbbeb
var1 = "Shoutting"  #the second 't' is the index 5 
var2 = "computer"  #the 'e' is -2 index

thank you Jeremy Hill you'r the best

You're welcome :)