Home > other >  Python board=[[None for _ in range (n)] for _ in range (n)] is what mean?
Python board=[[None for _ in range (n)] for _ in range (n)] is what mean?

Time:09-27

If inscribe!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

CodePudding user response:

[[None, None, None, None, None], [None, None, None, None, None], [None, None, None, None, None], [None, None, None, None, None], [None, None, None, None, None]]

If n=5, is a list of 5 * 5 content to none

CodePudding user response:

This code means is equivalent to:
 board=[] 
For I in range (n) :
List_1=[]
For j in range (n) :
List_1. Append (None)
Board. Append (list_1)

Just so we can simplify the code
  • Related