List Comprehension: Elegant way to create new List
从现有列表中创建新列表。
List comprehension包含一个表达式,后跟方括号内的for语句。
Here is an example to make a list with each item being increasing power of 2.
pow2 = [2 ** x for x in range(10)]
print(pow2)
[1, 2, 4, 8, 16, 32, 64, 128, 256, 512]