How to detect when a maximum number is rolled?
<p>This question seems like it would be easily answered by just making an if statement for my maximum in the range, BUT please take a second to read before calling me an idiot. I am making a program that lets the user choose between many different dice. I am wondering if there is an easy way to detect when the maximum value is rolled from any of the options without setting if statements for all of the different dice.</p>

<pre><code>def inphandle(choice):
    if choice==4:
        roll = random.randint(1,4)
    elif choice==6:
        roll = random.randint(1,6)
    elif choice==8:
        roll = random.randint(1,8)
    elif choice==10:
        roll = random.randint(1,10)
    elif choice==20:
        roll = random.randint(1,20)
    return roll

def dice(roll):
    min = 0
    if roll==1:
        print("Min roll! Try again!")
        min = min+1
    if roll 


def mainmenu():
    print("Please choose from the following options:")
    print("Roll | EXIT")
    option = input()
    if option=="EXIT" or option=="exit" or option=="Exit"
        print("You rolled" + max + "max rolls and " + min + " min rolls! Goodbye!")

def main():
    choice = int(input("Please enter a number corresponding to the number of faces on your dice. E.x. 4 for 4-Sided: "))
    cont = input("Would you like to roll the dice? Y or N: ")
    while cont=="y" or cont=="Y":
        roll = inphandle(choice)
        dice(roll)
        cont = input("Would you like to roll again? Y or N: ")
    while cont=="n" or cont=="N":
        easteregg()
        cont = input("Do I get bunus points now?!?")
main()
</code></pre>

<p>I do have random imported, but this is simply a section of the whole program. I understand if there is no shortcut to this, but I wanted to check before typing it all out since it might not be necessary. </p>

<p>This is what I would do:</p>

<p>change the inphandle to this:</p>

<pre><code>def inphandle(choice):
  roll = random.randrange(1,choice+1,1)
  return roll
</code></pre>

<p>And change main() to:</p>

<pre><code>def main():
  choice = int(input("Please enter a number corresponding to the number of faces on your dice. E.x. 4 for 4-Sided: "))
  valid_inputs = [4,6,8,10,12]
  if choice not in valid_inputs:
    print('Valid inputs are: 4,6,8,10,12. Try again.')
    main()
  cont = input("Would you like to roll the dice? Y or N: ")
  while cont=="y" or cont=="Y":
    roll = inphandle(choice)
    dice(roll)
    cont = input("Would you like to roll again? Y or N: ")
  while cont=="n" or cont=="N":
    easteregg()
    cont = input("Do I get bunus points now?!?")
</code></pre>

<p>Just a bit of clarification on the random.randrange:</p>

<pre><code>random,randrange('from','to','increments')
</code></pre>

<p>from is the minimum value and to is the maximum value EXCEPT it self.
so if u want a range of 1 to 4, put 1 to 5.
increment: put 1 for increments of "1", so possible outputs with be 1, 2, 3 or 4 instead of like 1.3252342 or 2.446211</p>

python if-statement random