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 Dates and Times in Python (2014) Let's Build a Timed Quiz App The Quiz Class

Ashley Keeling
Ashley Keeling
11,476 Points

underscore in python, for loops

is the underscore for when people look at the code or for python, or for both

2 Answers

Stuart Wright
Stuart Wright
41,120 Points

That's just a convention which shows the human reading the code that you never intend to access the value stored by that variable. So in the video, he just wants his code to repeat something 10 times, but he doesn't care which number _ is at any point. He could have used for i in range(10) and it would still have worked, but usually you'd only do that if you needed to access i.

Dave Huckle
Dave Huckle
7,030 Points

Additionally, if you declare a variable, you should also use it. "_" makes clear, there is no use.