1 回答

TA貢獻1848條經驗 獲得超2個贊
除非我遺漏了什么,否則 Python 使用縮進來表示作用域而不是大括號 ( {})。
修復這個問題,以及一些奇怪的縮進,test如果這就是你想要的,它會打印“”
import random
deste=[10,10,10,10,9,8,7,6,5,4,3,2,1,
10,10,10,10,9,8,7,6,5,4,3,2,1,
10,10,10,10,9,8,7,6,5,4,3,2,1,
10,10,10,10,9,8,7,6,5,4,3,2,1]
desteo=[]
desteb=[]
pas=3
oyunbitti=0
desteo.append(random.choice(deste))
deste.remove(desteo[-1])
desteb.append(random.choice(deste))
deste.remove(desteb[-1])
def hamle():
print("Destenin de?eri : ",sum(desteo))
print("Bilgisayar destesinin de?eri : ",sum(desteb))
print("Kalan pas hakk?n: ",pas)
yanit=input("Hamleni yap:\n1 Kart al\n2 Pas ge?\n")
if yanit==1: # don't use curly braces
desteo.append(random.choice(deste)) # these have been indented
deste.remove(desteo[-1])
if sum(desteo)>21: # no curly braces here either
oyunbitti=1
print("test")
添加回答
舉報