我想用Python創建一個小型博彩應用程序,當我嘗試運行該程序時,什麼也沒有發生。我正在使用IDLE。 這是我的代碼:Python - 試圖運行代碼時什麼都不會發生。我甚至沒有得到一個錯誤
def bet():
#balance = 100
x = 0
with open("bal.txt", "r") as f:
for l in f:
bal = (sum([int(a) for a in l.split()]))
while bal > 0:
print ("Your balance is: " + str(balance) + " credits.")
while x == 0:
print ("Enter the amount you would like to bet:")
bet = int(input())
if bet > bal:
x = 0
elif bet < 0:
x = 0
else:
x = 1
print ("Pick a number between 1 and 20")
num = int(input())
convbal = bal - bet
print ("Your bet is now locked in...")
print (" ")
print (" ")
import random
rannum = random.randint(1, 20)
print ("Your guess was: " + str(num))
print (" ")
print ("The random number was: " + str(rannum))
if rannum == num:
print ("WINNER")
bal = bal + (bet * 2)
else:
print ("LOSER")
print ("")
print ("")
這是我的結果收到殼:
任何想法將是巨大的,謝謝:)
你叫賭()?如果是這樣,請再打幾個電話打印以查看實際運行的循環。 –
這是你的全部代碼嗎?它只是一個你不稱之爲的功能! –
它取決於'bal.txt'的內容。 – Zety