Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Use range() or xrange() to Track Loop Index

Give Feedback

In the last lesson, you saw the sort of loop you might expect a developer coming from a C-style language to write in Python. In this lesson, you’ll see how you can use the range() and xrange() built-ins to make your loops more Pythonic.

The original loop keeps track of the loop index manually, which isn’t very Pythonic. You can instead keep track automatically if you use range() in Python 3 and xrange() in Python 2. A range object is a generator in Python.

Become a Member to join the conversation.