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()