1
我試圖寫一段代碼,根據國家彩票進行概率計算。 但我遇到了代碼運行方式的問題。
它每打印一次5次而不是創建一組新的隨機數,有人知道爲什麼嗎?隨機列表產生的塊不是單獨的行
gen = True
while gen == True:
#Generate Numbers
a = random.randint(1,59)
b = random.randint(1,59)
c = random.randint(1,59)
d = random.randint(1,59)
e = random.randint(1,59)
f = random.randint(1,59)
#Create tickets as lists
ticket = []
balls = []
#print the tickets
for i in ticket:
g = ticket[0]
h = ticket[1]
i = ticket[2]
j = ticket[3]
k = ticket[4]
l = ticket[5]
for i in balls:
m = balls[0]
n = balls[1]
o = balls[2]
p = balls[3]
q = balls[4]
r = balls[5]
print("TICKET")
print(g,h,i,j,k,l)
time.sleep(4)
print("BALLS")
print(m,n,o,p,q,r)
謝謝任何人,不勝感激。
你已經張貼不會打印任何東西,因爲'ticket'和'balls'是空列表的代碼。 – EngineerCamp