试图用 Python 制作游戏.. 虽然我似乎无法让某些代码工作?!快把我逼疯了!
任何帮助是极大的赞赏!
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 相同,它就不会打印 'You hit the post...' 它就结束了!
谢谢!