I'm very new to Python and to test my knowledge, I'm trying to build a Black Jack game. The code is rather long at this points, everything works fine, the following code is the only problem:
def player_round_end():
global player_points
if player_points_one == player_points_two:
# This works just fine
elif player_points_one != player_points_two:
print(f"---{player_points_one} or {player_points_two}")
if player_points_one or player_points_two == 21: #This is the probelem
print("---Black Jack!")
if player_points_one == 21:
player_points = player_points_one
else:
player_points = player_points_two
print(f"Player points: {player_points}")
dealer()
elif player_points_one and player_points_two > 21:
print("You lost!")
new_game()
I added some print functions so that I could easier find the bug. The problem with the == 21 statement is that it is sometimes defined as true, despite not beging true.
Example output from CMD:
---1 or 11
---Black Jack!
---Player points: 11
I drew and an A, which means that I have either 1 or 11 points. IT corectly defines that these are not equal, but it then defines that one of these is equal to 21, why is that? Let me know if you need more information or need to see all the code (though its not very pretty).
Aucun commentaire:
Enregistrer un commentaire