Save this video free

Python (Fall 2026) Module 6-7: Introducing for Loops

Bill Moseley, Ph.D. - Computer Science Educator · 18:00 · Watch on YouTube

Part of Bakersfield College COMP B10. See all 36 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

Bill Moseley introduces Python for loops as a way to run the same indented code once for each item in a sequence, contrasting them with condition-driven while loops. He demonstrates iterating through lists and dictionary keys, using range(start, stop, step) for counted loops, and formatting dictionary key-value output with ljust and rjust.

Key takeaways

Chapters

0:00 From While Conditions to Python For Loops Over Sequences
4:44 Using range() for Exclusive Stops and Counting Steps
8:48 Iterating Through Name Lists and Dictionary Keys

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:04 All right, welcome back everybody. Hope you had  a nice weekend. Today we're going to pick up the second half of module six, which is for loops.  If you remember, last time we talked about while loops, which were structured like this, and  we start with the keyword while. We have an expression that evaluates true or false. If the  expression is true, then it executes the indented block of code immediately beneath it. And we'll  continue to do that as long as the expression is true. So in this case, obviously we have the  expression is x is less than 4. When it starts out, x is one. So it prints it and then increments  one. It does that three times. And then on the

0:56 fourth round it will not repeat itself, because at  that point x will be equal to four. Again, if we look at this, that same code in a visual format.  So we're setting x to one, and we're asking is x less, not, than one. It says, I'm going to start  blinking again. We did so well last time. So it says, is x less than 11, different target number  but same effect. As long as it's less than 11, it will print the value of x and then increase  x by one, until x is no longer less than 11, at which point, I was starting to think it's  this chord maybe is like shorting out. I guess I'll have to like be very gentle about touching my  own computer here. So today we're going to go into

1:52 a different kind of loop. It's called a for loop.  And a for loop operates a little bit differently. Most important thing is that it's not based on  a condition, a true or false expression. Now it

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.