打破一个循环的次要原因

时间:2018-06-08 14:13:05

标签: python break

我正在制作一个轮盘赌游戏,这是我到目前为止所遇到的问题,因为我创造的游戏允许“现金”低于赌注。我试图添加一个赌注>现金,休息,但没有改变任何任何帮助赞赏

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)

0 个答案:

没有答案