Create an empty list in python with certain size

后端 未结 15 1682
有刺的猬
有刺的猬 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:22

    s1 = []
    for i in range(11):
       s1.append(i)
    
    print s1
    

    To create a list, just use these brackets: "[]"

    To add something to a list, use list.append()

提交回复
热议问题