'How to implement 3 times 6 on dice logic in snake and ladder

I have a scenario where I want to implement like when player continuously throws 3 times 6 on Dice. Then need to reset the score of player to old

For example :

Player 1 -> Dice : 6  -> Score -> 6   -> First  time 6 occurred on Dice 
Player 1 -> Dice : 6  -> Score -> 12  -> Second time 6 occurred on Dice 
Player 1 -> Dice : 6  -> Score -> 0   -> Third  time 6 occurred on Dice [ reset to old score ]

Code :

    ply1 0
    lst_of_palyers = ['Alice','Bob']
    flag=0
    countSix=0 

    while True:

        if flag == 0:

            dice_rolled_ply_1 = random.randint(1, 6)

            player_1_score = ply1 + dice_rolled_ply_1

            while True:

              if dice_rolled_ply_1 == 6 and countSix < 2:
                old_score = ply1
                store_previous_scores.append(old_score)
                store_previous_scores.append(player_1_score)
                ply1 = ply1 + dice_rolled_ply_1
                print({'PLAYER 1 ' : lst_of_palyers[i] , 'DICE ' : dice_rolled_ply_1 , 'SCORE ' : player_1_score , 'YOU GOT AGAIN CHANCE TO PLAY AS YOU ROLLED DICE 6':'PLAYER 1'}) 
              else:
                player_1_score=store_previous_scores[0]
                ply1=player_1_score
                print({'PLAYER 1 ' : lst_of_palyers[i] , 'DICE ' : dice_rolled_ply_1 , 'SCORE ' : player_1_score , 'CONTINOUS 3 TIMES 6 YOU ROLLED ON DICE' : 'PLAYER 2 GET CHANCE TO PLAY'})
                store_previous_scores.clear()
                flag=1
                break;

            else:

                    # Snake checking 
                    if player_1_score in snakes:

                      ply1 = snakes[player_1_score]
                      del snakes[player_1_score]
                      player_1_score = ply1
                      print({'PLAYER 1 ' : lst_of_palyers[i] , 'DICE ' : dice_rolled_ply_1 , 'SCORE ' : player_1_score , "OOP's YOU GOT A SNAKE " : 'PLAYER 1'})
                      flag=1

                    else:

                        if player_1_score in powerupladder_ply_1:
                          ply1 = powerupladder_ply_1[player_1_score]
                          del powerupladder_ply_1[player_1_score]
                          player_1_score = ply1                    
                          print({'PLAYER 1 ' : lst_of_palyers[i] , 'DICE ' : dice_rolled_ply_1 , 'SCORE ' : player_1_score , "YOU GOT A LADDER , PLAY AGAIN " : 'PLAYER 1'})
                          flag = 0
                        
                        else:

                          ply1 = ply1 + dice_rolled_ply_1
                          print({'PLAYER 1 ' : lst_of_palyers[i] , 'DICE ' : dice_rolled_ply_1 , 'SCORE ' : player_1_score})
                          flag = 1

Error :

Index out of range at this point : player_1_score=store_previous_scores[0]

Logic I am trying to implement like

If player throws dice as 6 then he will get again chance to play game , he will exit the control and control will be sent player 2 if continuous 3 times 6 as not occuered. If 3 times 6 occurred on dice then reset the score of player 1 and send control to player 2 to roll the dice



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source