Answer the question
In order to leave comments, you need to log in
How to make a 2D array with manual input?
I recently started learning Python and ran into a problem - I need to write a program that takes a rectangular matrix as a sequence of lines as input, ending with a line containing only the string "end".
Tried to implement something, in the end nothing comes out. I do not understand how to make an empty two-dimensional list filled line by line.
list =
cnt = 0
while 0 == 0:
cw = [int(i) for i in input().split()]
if 'end' in cw:
break
list[cnt] = cw
cnt += 1
for i in range(len(list)):
for j in range(len(list[i])):
print(j, end=' ')
print()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question