Create an empty list in python with certain size

后端 未结 15 1651
有刺的猬
有刺的猬 2020-11-22 12:00

I want to create an empty list (or whatever is the best way) that can hold 10 elements.

After that I want to assign values in that list, for example this is supposed

15条回答
  •  独厮守ぢ
    2020-11-22 12:21

    Here's my code for 2D list in python which would read no. of rows from the input :

    empty = []
    row = int(input())
    
    for i in range(row):
        temp = list(map(int, input().split()))
        empty.append(temp)
    
    for i in empty:
        for j in i:
            print(j, end=' ')
        print('')
    

提交回复
热议问题