Python赌大小

import random
money = 15
while money >= 5:
    print("您的余额为:", money)
    Y = input('是否继续赌博?【yes/no】:')
    while True: #非法输入无效
        if Y == 'yes' or Y == 'no':
            break
        else:
            Y = input("输入有误,请重新输入【yes/no】...")
    if Y == 'yes':
        large = input("【大/小】:")
        while True:
            if large == '大' or large == '小':
                break
            else:
                large = input("输入有误,请重新输入...【大/小】:")
        numList = [] #用于添加色子的点数
        sum = 0
        for i in range(3):
            numList.append(random.choice(range(1, 7)))
            sum += numList[i] #三个色子点数相加
        if sum < 11:
            print(numList, "%d点小" % sum)
            if large == '小':
                print("恭喜您中了大奖!")
                money += 5
            else:
                print("谢谢惠顾")
                money -= 5
        else:
            print(numList, "%d点大" % sum)
            if large == '大':
                print("恭喜您中了大奖!")
                money += 5
            else:
                print("谢谢惠顾")
                money -= 5
    else:
        print("您的余额为:", money)
        print("谢谢光临,欢迎下次再来!")
        break
else:
    print("您的余额不足,还有money =", money)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值