KiRaSmile
all right?

python随机获得1-9数字放入列表中

2019-03-12 Python
Word count: 52 | Reading time: 1min
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.

< PreviousPost
字符串中输出奇数字符
NextPost >
Python键盘输入转换为列表
CATALOG