python 年會抽獎小程序
import random
name = ["a","b","c","d","e","f","g"] #定義抽獎列表
for i in range(3):
a = random.choice(name) #隨機抽取內容
name.remove(a)
print(f"恭喜{a}抽中泰國5日游")
inn = input("是否進行下次抽獎(y/n):")
if inn == "y":
print("繼續進行二等獎抽獎")
else:
exit("輸入內容不正確")
for i in range(2):
b = random.choice(name)
name.remove(b)
print(f"恭喜{b}抽中phone⼿機")
innn = input("是否進行下次抽獎(y/n):")
if innn == "y":
print("繼續進行一等獎抽獎")
else:
exit("輸入內容不正確")
for i in range(1):
c = random.choice(name)
name.remove(c)
print(f"恭喜{c}抽中避孕套⼀盒")