Lecture 19 — Problems on Design

Overview

  • Review of Problem Solving and Design.

  • Introducing List Comprehensions: An alternate way to generate Lists

  • In Python, list comprehensions are constructed like so:

    list_variable = [x for x in iterable]

  • A list, or other iterable, is assigned to a variable.

  • Additional variables that stand for items within the iterable are constructed around a for statement.

  • The in keyword is used as it is in for loops, to iterate over the iterable.