Created
March 10, 2019 07:41
-
-
Save HoweChen/b7782d3bd064a760cb353c0dd3827158 to your computer and use it in GitHub Desktop.
[Initiate new list with default value]Initiage new list with default value #Python
This file contains 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
target_num = 0 | |
length = 100 | |
# two methods | |
# 1 | |
a = [target_num for x in range(length)] | |
# 2 | |
b = [target_num] * length |
This file contains 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
length = 100 | |
a=[[] for x in range(length)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment