|
本帖最后由 python大白白 于 2021-7-20 17:24 编辑
import random
tea = ['A','B','C','D','E','F','G','H']
name = [[], [], []]
print(name)
for i in tea:
fname=random.randint(0,2)
sname=name[fname].append(i)
print(sname)
print(name)在for循环遍历里面,sname变为none了这是为什么??结果:
[size=17.0667px][[], [], []]
[size=17.0667px]None
[size=17.0667px][['A', 'D', 'G'], ['E', 'H'], ['B', 'C', 'F']]
[size=17.0667px]Process finished with exit code 0
|
|