import random
a = int(input())
list = []
i=0
c=0
while i < a:
list.append(random.randint(0,9))#从1-9中随机选取数字添加入列表中
i+=1
for b in list:
if b <= 5:
c+=1
print(list)
print(c)
Author: KiRaSmile
Link: http://yoursite.com/2019/03/12/python随机获得1-9数字放入列表中/
Copyright: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.