0

mini dice game, roll 5 dice, if that is no repeated number will reroll till there is repeated number.

it crush till to due RecursionError after a few roll, i have no idea what is going on

import random

def roll():
  roll1 = random.randint(1,6)
  roll2 = random.randint(1,6)
  roll3 = random.randint(1,6)
  roll4 = random.randint(1,6)
  roll5 = random.randint(1,6)
  

  result = [roll1,roll2,roll3,roll4,roll5]
  
  result.sort()

  def check():
    while result == [1,2,3,4,5] or result == [2,3,4,5,6] or result == [1,3,4,5,6] or result == [1,2,4,5,6] or result == [1,2,3,5,6] or result == [1,2,3,4,6]:
      roll()
    else:
      print(result)
     
  check()

roll()

0 Answers0