File size: 521 Bytes
c585826
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import random

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

def main():
    print("Welcome to the dice roller!")
    while True:
        print("Enter 'q' to quit.")
        user_input = input("Roll the dice? ")
        if user_input.lower() == 'q':
            break
        else:
            try:
                result = roll_dice()
                print(f"You rolled a {result}!")
            except ValueError:
                print("Invalid input, please enter a number.")

if __name__ == "__main__":
    main()