The idea is to play die game using python.To do so we will take help from "Random Library". Random Library will allow us to generate random values which is defined within the limits of user to do so.
Step 1.Import Random Library import random Step 2. Define a Variable
x = "y"
Step 3. Use a loop to define the limits of the values for random function
while x == "y": num = random.randint(1,6)
Step 4. Terminate the loop at users will x=input("Press Y to roll again and N to exit:")
Hence by doing this we will able to play any game which uses die.For example you need next number for snake and ladders is 3 and below is the output which you will see.
[-----] [ ] [0 0 0] [ ] [-----]
Click on the image to check the code.