Answers for "Write a function that takes a two-dimensional list (list of lists) of numbers as argument and returns a list which includes the sum of each row. You can assume that the number of columns in each row is the same."

2

scanning 2d array in python

If you want to take n lines of input where each line contains m space separated integers like:

1 2 3
4 5 6 
7 8 9 

a=[] // declaration 
for i in range(0,n):   //where n is the no. of lines you want 
 a.append([int(j) for j in input().split()])  // for taking m space separated integers as input
Posted by: Guest on July-07-2020
0

initialise a 2d array python

x = [[foo for i in range(10)] for j in range(10)]
# x is now a 10x10 array of 'foo' (which can depend on i and j if you want)
Posted by: Guest on April-16-2020

Code answers related to "Write a function that takes a two-dimensional list (list of lists) of numbers as argument and returns a list which includes the sum of each row. You can assume that the number of columns in each row is the same."

Python Answers by Framework

Browse Popular Code Answers by Language