“So nehmen Sie Input in 2D -Liste in Python ein” Code-Antworten

Scannen von 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
Annoying Anteater

So geben Sie 2-D-Array in Python ein

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
Clean Chamois

So nehmen Sie Input in 2D -Liste in Python ein

rows,column=[int(x) for x in input().split()]
list=[[int(input()) for i in range(column)] for j in range(rows)]
Aggressive Alligator

Ähnliche Antworten wie “So nehmen Sie Input in 2D -Liste in Python ein”

Fragen ähnlich wie “So nehmen Sie Input in 2D -Liste in Python ein”

Weitere verwandte Antworten zu “So nehmen Sie Input in 2D -Liste in Python ein” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen