#游戏开始,首先玩家选择大小,选择完成后开始摇骰子(11<=总值<=18为大,3<=总值<=10为小) import random def roll_dice(numbers=3,points=None): # 创建3个筛子numbers,创建点数points print('<<<<roll the dice!>>>>') if points is None: points = [] # 把点数放到一个空的列表里 while numbers > 0: point = random.randrange(1,7) points.append(point) numbers = numbers - 1 return points def roll_result(total): # 判断大小 isbig = 11 <= total <= 18 issmall = 3 <= total <=10 if isbig: return 'big' elif issmall: return 'small' def start_game(): print('<<<<GAME STRATS!>>>>') choices = ['big','small'] your_choice = input('big or small:') if your_choice in choices: points = roll_dice() total = sum(points) youwin = your_choice == roll_result(total) if youwin: print('The points are',points,'YOU WIN!') else: print('The points are',points,'YOU LOSE!') else: print('invalid words') start_game() start_game()