Loading topic
for loop over a list, know what a tuple is, and can read basic dictionary code. Here you learn to unpack tuples directly in the for line. The later chapters on enumerate and zip rely on this skill.3 min readfor loop over a list, index into lists and tuples, and call functions such as len() and range(). It explains why the two usual ways of tracking position in a loop cause trouble. The next chapters show the replacement.4 min readfor loop over a list, know what a tuple is, and have seen unpacking such as a, b = (1, 2). Earlier chapters covered iterators and the problems with range(len(seq)). Here you will use enumerate to fix those problems.3 min readfor loop over a list, unpack a tuple in the loop header, and use enumerate to get an index and a value together. If for index, value in enumerate(items) looks unfamiliar, review the previous chapter first.3 min readenumerate.3 min readfor loop over a list, unpack tuples in a loop header, and use zip to loop over two sequences in parallel. Here you will see what zip does when its inputs have different lengths, and how to choose a different behavior on purpose.3 min readfor loop over a list, unpack a tuple into several names, and use enumerate and zip on their own. Here you combine them to get a position and several parallel values in one loop.3 min readzip that reshape data instead of just looping over it: building a dictionary from two parallel lists, and splitting a list of pairs back into separate sequences. It assumes you know how zip pairs items, how tuple unpacking works in a for loop, and the basics of 3 min readfor loops over lists, unpack tuples in a loop header, and use enumerate and zip for basic cases. Here you will learn why both functions return objects that can be read only once, and how to avoid the bugs this causes.3 min read