Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

create 2d array python list comprehension

#by taking the user input
def main():
    #write your code here
    row = int(input())
    col  = int(input()
    
    #using the list comprehensions
    matrix = [[int(input())for j in range(col)]for j in range(row)]
    #display the matrix
    for i in range(row):
        for j in range(col):
            print(matrix[i][j],end=" ")
        print()

if __name__ == "__main__":
    main()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #array #python #list #comprehension
ADD COMMENT
Topic
Name
9+1 =