我正在尝试在python中创建一个随机列表。每次您运行代码时,列表中的随机单词都会按顺序出现。我试图做的是:
import random
numSelect = 0
list = ['thing1', 'thing2', 'thing3', 'thing4', 'thing5']
for i in range(random.randint(1, 3)):
rThing = random.choice(list)
numSelect = numSelect + 1
print(numSelect, '-' , rThing)
目的是要求用户从列表中选择要显示的内容。这是我想要的输出示例:
1 - thing4
2 - thing2
Which one do you choose?:
(User would type '2')
*output of thing2*
元芳怎么了
婷婷同学_
相关分类