为什么他打印出来的是20个一模一样的号码啊
{:10_266:}难道不应该是20个随机的吗import random
a = []
def what():
count1 = count2 = 0
while count1 < 3:
x = random.randint(65,91)
a.append('{:c}'.format(x))
count1 += 1
while count2 < 3:
x = random.randint(0,9)
a.append(x)
count2 += 1
for i in range(6):
print(a,end='')
print('请选择你的车牌')
count3 = 0
while count3 < 20:
what()
print(end=' ')
count3 += 1
if count3 % 4 == 0:
print() a=[]位置不对挪函数里面就好了
def what():
a = []
count1 = count2 = 0
while count1 < 3:
x = random.randint(65,91)
a.append('{:c}'.format(x))
count1 += 1
while count2 < 3:
x = random.randint(0,9)
a.append(x)
count2 += 1
for i in range(6):
print(a,end='') wp231957 发表于 2021-7-28 13:18
a=[]位置不对挪函数里面就好了
!真的可以,谢谢了!顺便可以问下是什么原理吗QWQ fucku 发表于 2021-7-28 13:38
!真的可以,谢谢了!顺便可以问下是什么原理吗QWQ
你按我的代码修改一下,相信你自己就知道为什么了
import random
a = []
def what():
count1 = count2 = 0
while count1 < 3:
x = random.randint(65,91)
a.append('{:c}'.format(x))
count1 += 1
while count2 < 3:
x = random.randint(0,9)
a.append(x)
count2 += 1
print(a)
#for i in range(6):
#print(a,end='')
print('请选择你的车牌')
count3 = 0
while count3 < 20:
what()
print(end=' ')
count3 += 1
if count3 % 4 == 0:
print()
页:
[1]