Created
June 20, 2021 05:36
-
-
Save AntiKnot/3f6dd822daadea09d39d8c099446b29d to your computer and use it in GitHub Desktop.
python init 2vector matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # right | |
| def init_matrix(n,m): | |
| return [[0 for _ in range(n)] for _ in range(m)] | |
| # wrong | |
| # In this way, the rest of the positions will also be modified when the value is modified. | |
| def init_matrix_wrong(n,m): | |
| return [[0] * n] * m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment