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 trialNadia Balogou
212 PointsI 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
varl = "repete"
2 Answers
Alexander Davison
65,469 PointsGreat job! 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 )
var1 = "aaaaat"
Hope that helps!
Steven Parker
231,261 PointsYou have two issues here:
- the challenge asks for avariable named
var1
(ending in a numeral one), you havevarl
(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"