Exercises
A few exercises were already suggested. Let's list a few of these. (Note that the solution are not provided for these exercises.):
Write a list comprehension syntax for a nested
forloop. Compare the timings of a nestedforloop and the list comprehension. Here is an example:x = [ i*j for i in range(4) for j in range(4)]
Write a generator expression for the preceding list comprehension. You just need to change the outer square brackets
[]to the round brackets().