試圖在Python中做一個遊戲..雖然我似乎無法得到一定的代碼工作?!這讓我瘋狂!Python遊戲inbetween - 不能得到if-elif工作
任何幫助,非常感謝!
import random
die1 = random.randint(1,10)
die2 = random.randint(1,10)
die3 = random.randint(1,10)
if die1 > die2:
print ('Die 1:', die2,' Die 2:', die1,)
else:
print ('Die 1:', die1,' Die 2:', die2,)
if die1 == die2 or die2 == die1:
print('\nEven-steven!')
else:
print('\nNot the same, let\'s play!')
print ('\nDie 3:', die3,)
if die3 > die1 and die3 < die2 or die3 < die1 and die3 > die2:
print ('\n*** You win! ***')
elif die1 > die2:
if die3 < die2 or die3 > die1:
print('\n*** Sorry - You lose! ***')
elif die2 > die1:
if die3 < die1 or die3 > die2:
print('\n*** Sorry - You lose! ***')
**elif die3 == die1 or die3 == die2:
print ('\n*** You hit the post - You lose double your bet! ***')**
print ('\nThanks for playing!')
這是在第二個if語句結構,不管出於什麼原因,如果die1或die2是一樣的die3,它只是將無法打印「你擊中門柱......」它只是結束!
謝謝!
非常非常感謝! – user2286906