I am making a game in python and I have encountered a problem where an infinite has been created. I'm new to programming and I'm not sure how to fix it. Any help would be amazing.
money = 100
opp = dealer()
me = player()
while money > 0:
if me > opp:
money = money * 1.5
print "Winner, winner, chicken dinner! You have $%d!" % money
elif opp > me:
money = money * 0.75
print "Dealer wins with %d. You have $%d reamaining." % (opp, money)
elif me == 21:
money = money * 1.5
print "Blackjack! You have $%d!" % money
The code is doing exactly what I've asked from it (which is to print the line). How can I make it print the line once and then just restart and deal new cards.
Move the code that reads the dealer and the player hands to the beginning of loop:
while money > 0:
opp = dealer()
me = player()
if me > opp:
money = money * 1.5
print "Winner, winner, chicken dinner! You have $%d!" % money
elif opp > me:
money = money * 0.75
print "Dealer wins with %d. You have $%d reamaining." % (opp, money)
elif me == 21:
money = money * 1.5
print "Blackjack! You have $%d!" % money
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With