Answers for "Write a function matrix(rows: int, cols: int) in python"

1

how to input 2-d array in python

matrix = [input().split() for i in range(no_of_rows)] # if only row is given and the number of coloumn has to be decide by user
matrix= [[input() for j in range(no_of_cols)] for i in range(no_of_rows)] # if both row and coloumn has been taken as input from user
Posted by: Guest on April-27-2020
0

We pass in a 2 dimensional list. You should output the 3rd element of the 2nd row.

In a 2 dimensional list, output the 3rd element of the 2nd row.
# remember to account for 0 index
print(variable[1][2])
Posted by: Guest on January-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language