Python新手在这里。我正在尝试创建一个用户与计算机对战的二十一点游戏。我认为我遇到的问题是这里的 if, elif 语句。我想知道的是,当我没有 else 语句时,如果不满足任何 if 和 elif 语句的条件会发生什么?这里没有 else 语句有问题吗?
def game_winner(n):
p_wins = 0
d_wins = 0
for i in range(n):
player_sum = player_game()
dealer_sum = dealer_game()
if player_sum > dealer_sum and player_sum <= 21:
p_wins = p_wins + 1
elif dealer_sum > 21 and player_sum <= 21:
p_wins = p_wins + 1
elif player_sum > 21 and dealer_sum <= 21:
d_wins = d_wins + 1
elif dealer_sum > player_sum and dealer_sum <= 21:
d_wins = d_wins + 1
return p_wins, d_wins