我如何改善这个简单的骰子滚动项目

因此,这是我自己做的我的初学者项目的另一个,只是想要有关改进此代码的任何提示或想法,以及如何在该项目中实现更高级别的python。

import random
#Size choosing for dice
while True:
    #Choosing the minimum number
    Min = input("Please input the minimum number of your dice: ")
    try:
        Min = int(Min)
    except ValueError:
        print("Invalid input")
        continue
    #Choosing the maximum number
    Max = input("Please input the maximum number of your dice: ")
    try:
        Max = int(Max)
    except ValueError:
        print("Invalid input")
        continue
    #Check if the minimum and maximum is valid
    if Min > Max:
        print("Minimum is bigger than Maximum.\n Please reinput data...")
        continue
    elif Min == Max:
        print("Minimum is equaled to Maximum,\n Please reinput data...")
        continue
    print(f"Your dice is from {Min} to {Max}.")
    break

#Random number generater
while True:
    Rollcount = input("How many times do you want to roll the dice: ")
    try:
        Rollcount = int(Rollcount)
        break
    except ValueError:
        print("Invalid input")
        continue
for i in range(0,Rollcount):
    roll = random.randint(Min,Max)
    print(roll)
评论