"For loop: For I in Range (X,y,dir): Pass First this interval is left closed right open second dir in the case of omitting the default is 1, that is, each time plus one, you can also specify the python array: Python is not an array, But you can use list instead of array one-dimensional arrays: Method One: Arr=[0 for x in range (0,n)] Method Two: Arr=[0]*10 method One and method two are equivalent two-dimensional arrays: Method One: Arr=[[0 for x in range (0,n)] for y in Range (0,m)] method two: Arr=[[0]*3]*3 but the two are different in the second method, if arr[0][1]=3, then arr=[[0,3,0],[0,3,0],[0,3,0]] Reason: the Python standard The library is the list * N->n shallow copies of list concatenated, n a shallow copy of the list of connections, as long as one of the changes, the other will also follow the change "#计蒜客: Matrix Flip #!/usr/bin/ python#-*-coding:utf-8-*-import mathn,m,ty=[int (x) for x in input (). Strip (). Split ()]arr=[[0 for x in range (0,n)] for y In range (0,m)]for I in Range (0,n): arr[i]=input (). Split (") if ty==0: for i in range (0,n): for J in range (m-1 , -1,-1): print (arr[i][j],end= "") print () Else: for i in range (n-1,-1,-1): for J in Range (0,m): Print (arr[i][j],end= "") print ()
Creation, input and output of two-dimensional arrays in Python