Python随机点名代码

随机点5个人名

name_list = [“张三”, “李四”, “王五”, “王麻子”, “赵六”, “钱七”, “孙”, “周”, “吴”, “郑”]

import random

count = 1

while count <= 5:

name = random.randint(0, len(name_list) - 1)

print(name_list[name])

count += 1

del name_list[name]

猜你喜欢

转载自blog.csdn.net/li_little_flower/article/details/108712147