How to simulate rolling two dice (game cubes) with values 1–6 in Python

1 Answer

0 votes
import random

def roll_dice():
    return random.randint(1, 6)   # 1–6 inclusive

def main():
    dice1 = roll_dice()
    dice2 = roll_dice()

    print("Dice 1:", dice1)
    print("Dice 2:", dice2)

if __name__ == "__main__":
    main()


 
'''
run:
 
Dice 1: 1
Dice 2: 3

'''

 



answered Feb 18 by avibootz

Related questions

...