Ask coding questions

← Back to all posts
Rolling Dice CodeHS. Please help :)

Hello Repel community,

I am stuck on a CodeHS question titled: Rolling Dice. Can you guys please help me with this, it means the world to me, thank you <3

Here is the problem :)

Write a python program that will print out all combinations that can be made when 2 dice are rolled.

Your output should look like this:

1, 1
1, 2
1, 3
1, 4
1, 5
1, 6
2, 1
2, 2
2, 3
2, 4
And should continue until all values up to 6, 6 are printed. (Hint: You should have a space after each comma!)

Because you know exactly how many times each loop should iterate, you should use nested for loops (a loop within a loop) to complete this program.

Answered by Codemonkey51 [earned 5 cycles]
View Answer

@LostWonderer found the solution, I am not going to tell you the code just some hints so that you will learn it not just copy (you can check your answer with the one on my profile named CodeHS) so you should make a list with numbers (in string form) 1 through 6 in order of least to greatest, so now how will you get it to print all the pairs all you will need to do is loop through the list multiple times printing the two roles with a for loop.

AKA: make a list containing ["1","2","3","4","5","6"] then have one for loop running around the list, then another for loop inside now it should run through all the solutions, the final problem is to just print it assuming the first for loop uses I and the second uses j you just need to print a combination of i , , , and j then just print the output of that

EDIT: you can check the code here


Thank you so much! Have a wonderful day :)


Your welcome, will do @LostWonderer


One sec I'll try to find a solution I'll ping you when I finish


thank you, you're awesome :)


Your welcome @LostWonderer