234k views
23 votes
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 i 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

User Johnnie
by
4.4k points

1 Answer

8 votes

for x in range(1,7):

for w in range(1,7):

print(str(x)+","+str(w))

I wrote my code in python 3.8. I hope this helps.

User Chetan Goenka
by
4.3k points