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 trialAngelus Miculek
6,293 Pointstriple quotes cause index errors
My code is this:
underhill = input('''{}, do you understand Python while loops?
(Enter yes/no) '''.format(name))
while underhill.lower() != 'yes':
underhill = input('''Ok, {}, Python while loops repeat as long as a certain Boolean condition is met.
{}, now do you understand Python while loops?
(Enter yes/no) '''.format(name))
print("That's great, {}. I'm pleased that you understand while loops now. That was getting repeatitive.".format(name))```
3 Answers
Travis Alstrand
Treehouse Project ReviewerHiya Angelus Miculek
This is actually happening because there are two { }
within that sentence it's showing in the error but only one variable to format it with provided. You'll simply need to add in name
twice like so...
while underhill.lower() != 'yes':
underhill = input('''Ok, {}, Python while loops repeat as long as a certain Boolean condition is met.
{}, now do you understand Python while loops?
(Enter yes/no) '''.format(name, name))
In your provided code above I assumed you still had this up top
name = input("What's your name? ")
Things seemed to be working fine after that addition 👍
Angelus Miculek
6,293 Pointstreehouse:~/workspace$ python looping.py
What's your name? a
a, do you understand Python while loops?
(Enter yes/no) no
Traceback (most recent call last):
File "/home/treehouse/workspace/looping.py", line 18, in <module>
underhill = input('''Ok, {}, Python while loops repeat as long as a certain Boolean condition is m
et.
IndexError: Replacement index 1 out of range for positional args tuple
No clue why this error happens when I say no. Is it the triple quotes?
Angelus Miculek
6,293 PointsThanks, Travis! You're a pro.
Travis Alstrand
Treehouse Project ReviewerYou're very welcome!! 😃