数组c中有32个数字,所有数字均为21。我想将位置0,5,10,18,21,24,28的数字替换为63。我该怎么做?
a =32
b = [0,5,10,18,21,24,28]
c = []
for i in range(a):
c.append(21)
答案 0 :(得分:1)
c
a = 32
b = [0, 5, 10, 18, 21, 24, 28]
c = [21] * a
list[index]
允许将值检索或分配给index
中特定的list
位置for x in b:
c[x] = 63
资源: