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

Nadia Balogou
Nadia Balogou
212 Points

I continue to get an error code for the variable that I want to set but I do not understand why

not quite sure why it is not defined

index.py
varl = "repete"

2 Answers

Great job! :thumbsup: This is the weird part about programming, and when I started programming for the first time, I didn't quite understand this either. The problem is Python (and almost every other programming language) starts counting from zero, so:

  • One will be zero
  • Two will be one
  • Three will be two
  • Four will be three
  • Five will be four
  • And so on and so forth

So when the challenge asks "Make sure index 5 is the letter t.", basically that means (if you start counting from one) to make sure index 6 to the letter t. Instead, try this code: (You try and do the next task :smile:)

var1 = "aaaaat"

Hope that helps! :dizzy:

Steven Parker
Steven Parker
229,608 Points

You have two issues here:

  • the challenge asks for avariable named var1 (ending in a numeral one), you have varl (ending in lowercase L)
  • the item with index 5 must be the letter 't'. Since indexes start at 0, your index 5 letter is 'e'.

If you use the common spelling of "repeat", the index 5 letter (the sixth letter) will be "t".

var1 = "repeat"