Home:ALL Converter>Breaking a while loop for a secondary reason

Breaking a while loop for a secondary reason

Ask Time:2018-06-08T22:13:04         Author:

Json Formatter

I am creating a roulette game, this is what I have so far, the problem arises in the fact that the game I have created allows "cash" to go below the bet. I tried to add a bet > cash , break but that didn't change anything any help appreciated

import random

bet = 1
cash = 100
counter = 1
result_1 = random.randint(1,10)

print ('Starting money £', cash) ;

if result_1 < 5:
    cash = cash + bet 

while (result_1 > 4):
    cash = cash - bet
    print ('Loss' ,counter, 'you have £', cash)
    counter = counter + 1
    result_1 = random.randint(1,10)
    bet = bet * 3
    if result_1 < 4:
        cash = cash + bet
    if cash < bet:
        break

print ('You won! Your money is: £', cash - 1 + bet)

if counter == 1:
    print ('It took you ', counter, 'attempt to win')

else:
    print ('It took you ', counter, 'attempts to win')  

print ('your largest bet was £' , bet)

Author:,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50762585/breaking-a-while-loop-for-a-secondary-reason
yy