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

jamie Macdiarmid
jamie Macdiarmid
2,048 Points

index

Make a new variable named var1 that is either a list or a string. Make sure that var1[5], the item with an index value of 5, is the letter "t".

Understood Kenneth's last video on indexes but the wording in the challenge confused me?

index.py

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

The challenge want you to create a variable var1 where the item at index 5 is the letter "t". Since indexes count starting at 0 this would be the 6th letter in a string or the 6th element in a list:

# as a string
var1 = 'marmot'

# as a list
var1 = ['a', 'y', 'b', 'x', 'c', 't']
jamie Macdiarmid
jamie Macdiarmid
2,048 Points

Hi Chris. Thanks for your response. Just wasnt sure what string or list they meant. I suppose when they said 'create' I should know. Thanks again

Jamie