Loading topic
for loop does not care what kind of object it walks over, as long as the object is iterable. This chapter shows which objects qualify and what the loop variable receives from each of them.2 min readprint()), lists, strings and integers, and how to run a Python 3 script.2 min readprint(), and how a basic for loop walks over a list.2 min readrange() and can write a basic for loop. Here you will use the third argument, step, to skip values and to count down.2 min readfor loop, call range() with one, two, or three arguments, and run a Python 3 script. Here you will see what a range object is, why it uses almost no memory, and which list-like operations it supports.2 min readfor loop, use range(), and know what a function is. It explains where the loop variable lives, what value it holds after the loop, and the mistakes that follow from that.2 min readfor loop and that you know range() takes start, stop and step arguments. It also assumes you can index a list with items[i].2 min readfor loop, know how range() and len() work, and can unpack a tuple into two variables. It covers enumerate(), the built-in that gives you each item together with its position.2 min readfor loop over a list, unpack a tuple into variables, and use enumerate(). It covers how zip() lets one loop walk through several iterables at the same time.2 min readfor loop over a list or range(), use if statements, and run a Python 3 script. By default a for loop visits every item. break and continue let you change that from inside the loop body.2 min readfor loop over a list or range(), and that you know how indentation marks a block. A nested loop is a loop placed inside the body of another loop.2 min readfor loop and use break and continue, as covered in the earlier chapters. It also assumes you know that range() produces integers.2 min readfor loop, know how lists and indexes work, and have seen range() and enumerate(). It explains one of the most common loop bugs: changing a list while a for loop is walking over it.3 min readfor loops, know lists, strings and range(), and can run a Python 3 script. It shows what Python does each time a for loop runs.2 min readfor loop, call range(), and use if statements and lists.2 min readfor loop, know range() with one, two or three arguments, and understand that a range object is a lazy sequence. Here we collect the mistakes that appear most often and show the fix for each.2 min read