import time
import random
print("Welcome to double up!")
pscore = 1
pscore = str(pscore)
print("Your current balance is "+pscore+", would you like to double or
quit?")
while pscore != 0:
pscore = str(pscore)
print("Your current balance is "+pscore+"!")
pscore = int(pscore)
choice = input("d/q :")
if choice == ("d")or("D"): #later simplify cases
luck = random.randint(1,100)
if luck > 75:
print("Upgrade failed!")
pscore = 0
else:
print("Upgrade complete!")
pscore = pscore * 2
else: #ERROR
print("Incorrect command! Please retry!")
標記爲#ERROR的代碼行不會運行,無論我輸入什麼變量'choice'都有幫助嗎?Python,if-else語句錯誤
我還希望我能做些什麼來幫助清理我的代碼,很新:對
https://pastebin.com/dPbpZfcy - 該代碼爲我搞砸了在這個網站
它絕對不應該運行。您有縮進錯誤。 –
@cᴏʟᴅsᴘᴇᴇᴅ你能告訴我在哪裏嗎? –
'如果選擇==(「d」)或(「D」):#later簡化案例'unindent這一級 – jacoblaw