.
import random
lotterys = random.sample(range(1,50), 7)
specialNum = lotterys.pop()
print("大樂透 中獎號碼: ", end="")
for lottery in sorted(lotterys):
print(lottery, end=" ")
print("\n特別號: ", specialNum)
print("過了今晚!")
執行結果範例:
PS D:\DevTool\ZCode> & C:/Python312/python.exe d:/DevTool/ZCode/_Code/_Python/BigLotterys.py
大樂透 中獎號碼: 13 19 22 34 40 43
特別號: 32
過了今晚!