这里的别的应该没有太大问题吧,就这里不知道为什么一直出现在第二列
好有趣啊,可以直接发个源码,我copy试试吗
import random
list = ['1','2','3','4','5']
listA = [' ',' ',' ',' ',' ']
listB = [' ',' ',' ',' ',' ']
listC = [' ',' ',' ',' ',' ']
listD = [' ',' ',' ',' ',' ']
listE = [' ',' ',' ',' ',' ']
space = True
total = [listA,listB,listC,listD,listE]
def main(l,index=0) :
if index == len(list):
return
xaxis = random.randint(0, 4)
yaxis = random.randint(0, 4)
count=0
while True:
while total[xaxis][yaxis] != ' ':
xaxis = random.randint(0, 4)
yaxis = random.randint(0, 4)
total[xaxis][yaxis]=list[index]
count+=1
if count==3:
break
index+=1
main(l,index)
if __name__ == '__main__':
main(list)
print(listA)
print(listB)
print(listC)
print(listD)
print(listE)