Basic cheatsheet for Python mostly based on the book written by Al Sweigart, Automate the Boring Stuff with Python under the Creative Commons license and many other sources.
a = [1, 3, 5, 7, 9, 11]
[i - 1 for i in a]b = {"abc", "def"}
{s.upper() for s in b}c = {'name': 'Pooka', 'age': 5}
{v, k for k, v in c.items()}A List comprehension can be generated from a dictionary:
c = {'name': 'Pooka', 'first_name': 'Oooka'}
["{}:{}".format(k.upper(), v.upper()) for k, v in c.items()]