Common Python shortcuts and tricks
[x for x in list if x > 0]List comprehension filter
[x * 2 for x in list]Transform each element
[x for sub in list for x in sub]Flatten nested list
list(set(my_list))Remove duplicates
"hello"[::-1]Reverse a string
", ".join(list)Join list to string
"hello world".split()Split string to list
open('file.txt').read()Read entire file
import json; json.loads(string)Parse JSON string
a, b = b, aSwap two variables