Question & Answer

Write a program that prints all possible dice rolls with two dice. To do so, you should use a nested for loop. Hint: You can’t use 1 for both for loops. Here’s what your program should print: 1, 1 1, 2 1, 3 1, 4 1, 5 1, 6 2, 1 … 6, 4 6, 5 6, 6

Write a program that prints all possible dice rolls with two dice. To do so, you should use a nested for loop.

Hint: You can’t use 1 for both for loops.

Here’s what your program should print

1, 1
1, 2
1, 3
1, 4
1, 5
1, 6
2, 1

6, 4
6, 5
6, 6

1 Answer

Verified archive
Quizzma TeamDecember 25, 2025

Here’s a simple program in Python that prints all possible dice rolls with two dice using nested for loops:


for die1 in range(1, 7): # Loop for the first die, from 1 to 6

for die2 in range(1, 7): # Loop for the second die, from 1 to 6

print(die1, ',', die2) # Print the current combination of dice rolls

### Explanation:
1. Outer Loop (`die1`): Iterates through numbers 1 to 6, representing the first die.
2. Inner Loop (`die2`): For each value of `die1`, this loop iterates through numbers 1 to 6, representing the second die.
3. Print Statement: Displays the current combination of the two dice rolls.

By using nested loops, the program successfully prints all combinations of dice rolls from (1,1) to (6,6). If you have any more questions, feel free to ask!