1. For循环
如果猜对,直接退出。
import random
list_1 = ["张1","张2","张3","张4","张5","张6","张7","张8","张9","张10","张11","张12","张13","张14","张15","张16","张17"]
list_2_1 = []
list_2_2 = []
list_2_3 = []
print("开始抽取三等奖")
for i in range(10):
lucker = random.choice(list_1)
list_2_3.append(lucker)
list_1.remove(lucker)
print("三等奖中奖人是:",list_2_3)
print("开始抽取二等奖")
for i in range(3):
lucker = random.choice(list_1)
list_2_2.append(lucker)
list_1.remove(lucker)
print("二等奖中奖人是:",list_2_2)
print("开始抽取一等奖")
for i in range(1):
lucker = random.choice(list_1)
list_2_1.append(lucker)
list_1.remove(lucker)
print("一等奖中奖人是:",list_2_1)
print("未中奖的人是:",list_1,"来年好运!")
网友评论