Skip to content
Advertisement

How do I print the result of the individual die in the dice roll program in python?

This is what I have so far:

JavaScript

I want to print the individual die as I already get the result.

Rolling 2d20…

Die 1: 1

Die 2: 15

Total: 16

Advertisement

Answer

You can add a print() statement inside the RollDice() function (though this will cause the generator to have the side effect of printing to the console, which may or may not be desirable depending on if you’re using this function elsewhere):

JavaScript
Advertisement