ECS 10 Study Guide - Midterm Guide: Hella Good, Newline, Lightning
Document Summary
Loops can appear within loops just like if statements can appear within if statements. Very common and useful break and continue in nested loops- Break and continue only break or continue out of the loop they immediately appear inside. ### write a function that will print out the multiplication table >>> def print_mult_table(num_rows, num_cols): >>> for row in range(1, num_rows + 1): >>> for col in range(1, num_cols + 1): >>> print("%3d" % (row * col), end= "") >>> print() >>> num_rows = int(input("enter the number of rows: ") >>> num_cols = int(input("enter the number of columns: ") Enumerate gives you both the position and the value when iterating through an iterable. Zip allows you to iterate over multiple iterables in parallel syntax zip(iter1, iter2, iter3, . ) For item1, item2, item3, in zip(iter1, iter2, iter3, . ) Iteration stops as soon as you reach the end of the shortest iterable lists-