Here are some tips when using Python and dealing with lists.
- Use snake_case for list variable names. For more information on coding style in Python, see the PEP 8 style guide here.
- Never call a variable "list". (If you are using a variable for a list, use something like small_list or big_list -- not "list".) Any word that is not a reserved word and not a built-in data type will work. You need to know the reserved words in Python because if you accidentally use them, it can cause a problem. To see words you should not try to use as variables, click here.
- To create a multi-dimensional array based on a variable input "n", use syntax like this:
cool_list = [[0 for x in range(n)] for y in range(n)]
- To print out the contents of each row of the multi-dimensional list, see this posting.