1"""
2List comprehension goes through the loops in the order you'd expect. Outer
3loops (first loops) are executed first, then inner loops.
4"""
5
6numbers = [1, 2, 3, 4, 5]
7letters = ['a', 'b', 'c', 'd', 'e']
8
9list_comprehension = [str(number)+letter for number in numbers for letter in letters]
10
11#which is the same as:
12typical_for = []
13for number in numbers:
14 for letter in letters:
15 typical_for.append(str(number)+letter)
16
17assert list_comprehension == typical_for
18
19print(list_comprehension)
20# ['1a', '1b', '1c', '1d', '1e',
21# '2a', '2b', '2c', '2d', '2e',
22# '3a', '3b', '3c', '3d', '3e',
23# '4a', '4b', '4c', '4d', '4e',
24# '5a', '5b', '5c', '5d', '5e']