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) Logic in Python Around and Around

While loop example

start = 99 while start: print("{} bottles of milk on the wall, {} bottles of milk.".format(start)) print("Take one down and pour it on some cereal.") start -= 1 print("{} bottles of milk on the wall.".format(start))

The above example is copied and pasted from the Teachers notes. I've tried to run/type this on my own unsuccessfully in the workspace environment and a python visualizer. Both return an error message "tuple index out of range". Please advise. Thank you!

1 Answer

Steven Parker
Steven Parker
231,269 Points

:point_right: There appears to be a bug in the example!

One of the lines of the example looks like this:

    print("{} bottles of milk on the wall, {} bottles of milk.".format(start))

It has a string with two placeholders, but it attempts to format it using only one argument. Try changing it to this:

    print("{} bottles of milk on the wall, {} bottles of milk.".format(start, start))

You may want to report this as a bug :beetle: using the Support page.