<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Python List Comprehensions
Notes for the article Python List Comprehensions
Step1:  Even with conditions in the for loop
Step2:  Nested loops in a list
Step3:  Another example of nested loops
Step4:  The article gives an example of how to flatten a matrix using this trick. Semantically, one would using
Step5:  which is obviously WRONG. The correct code is given by the author as
Step6:  The key is to write the nested loops in a list as the normal nested loops.
With this possible confusion, the author proposed a line breaking solution
<ASSISTANT_TASK:>
Python Code:
list_with_for_loop = [x for x in range(10)]
print list_with_for_loop
Explanation: Python List Comprehensions
Notes for the article Python List Comprehensions: Explained Visually by Trey Hunner
Making a List
Integrated with loops
End of explanation
list_with_for_loop_conditional = [x for x in range(10) if x%2 == 1]
print list_with_for_loop_conditional
Explanation: Even with conditions in the for loop
End of explanation
list_with_nested_loops = [ [x, y] for x in range(3) for y in range(3) ]
print list_with_nested_loops
Explanation: Nested loops in a list
End of explanation
list_with_nested_loops_2 = [ x for x in range(y) for y in range(3)]
print list_with_nested_loops_2
Explanation: Another example of nested loops
End of explanation
matrix = [[11,12],[21,22]]
row = [1,2]
wrong_flatten_of_matrix = [x for x in row for row in matrix]
print "matrix is", matrix
print "flattened matrix is", wrong_flatten_of_matrix
Explanation: The article gives an example of how to flatten a matrix using this trick. Semantically, one would using
End of explanation
right_flatten_of_matrix = [x for row in matrix for x in row]
print "matrix is", matrix
print "flattened matrix is", right_flatten_of_matrix
Explanation: which is obviously WRONG. The correct code is given by the author as
End of explanation
right_flatten_of_matrix_line_breaking = [
    x 
    for row in matrix 
        for x in row
]
print "matrix is", matrix
print "flattened matrix is", right_flatten_of_matrix_line_breaking
Explanation: The key is to write the nested loops in a list as the normal nested loops.
With this possible confusion, the author proposed a line breaking solution
End of explanation
<END_TASK>