2D arrays Flashcards
1
Q
How would you create a 2D array using list comprehension in Python?
A
arr = [[0] * 4 for i in range(4)]
2
Q
True or False: arr = [[0] * 4] * 4 is a valid way to initialize a 2D array using list comprehension?
A
False - any change to this list will effect every value in the list at the same index