I am trying to get a dice roller program that works for DND that you would enter number of dice, what sided dice and a modifier to add to the result. I had gotten it able to do just 1 dice without a problem but cannot seem to get it to work right for multiple dice. With the code as is, typing 7 doesn’t not exit the program as it should, when i print an answer, I get however many numbers of dice I chose lines. So, if I put 3 for number of dice, it is giving me the result of each dice plus modifier, not the sum of the dice + modifier in one line as I want.

I tried 2 ways:

way 1:

import random

run = True

print("""

Enter 1 for a D20

Enter 2 for a D12

Enter 3 for a D10

Enter 4 for a D8

Enter 5 for a D6

Enter 6 for a D4

Enter 7 to Exit

“”")

while run and end < num_dice:

number = input("Enter number of choice here: ")

num_dice = int(input("Enter number of dice being rolled: "))

modifier = int(input(“How much to modify the roll by?”))

end = 0

total = 0

```
if number == "1":
roll = int(random.randint(1, 20))
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier)+ " = " + str(outcome))
end += 1
elif number == "2":
roll = int(random.randint(1, 12))
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier) + " = " + str(outcome))
end += 1
elif number == "3":
roll = int(random.randint(1, 10))
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier) + " = " + str(outcome))
end += 1
elif number == "4":
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier) + " = " + str(outcome))
end += 1
elif number == "5":
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier) + " = " + str(outcome))
end += 1
elif number == "6":
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier) + " = " + str(outcome))
end += 1
elif number == "7":
run = False
```

way 2) (with same results)

import random

run = True

print("""

Enter 1 for a D20

Enter 2 for a D12

Enter 3 for a D10

Enter 4 for a D8

Enter 5 for a D6

Enter 6 for a D4

Enter 7 to Exit

“”")

while run:

number = input("Enter number of choice here: ")

num_dice = int(input("Enter number of dice being rolled: "))

modifier = int(input(“How much to modify the roll by?”))

end = 0

total = 0

while end < num_dice:

if number == “1”:

roll = int(random.randint(1, 20))

total += roll

outcome = total + modifier

print("Dice roll: " + str(total) + “+” + str(modifier)+ " = " + str(outcome))

end += 1

```
elif number == "2":
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier) + " = " + str(outcome))
end += 1
elif number == "3":
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier) + " = " + str(outcome))
end += 1
elif number == "4":
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier) + " = " + str(outcome))
end += 1
elif number == "5":
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier) + " = " + str(outcome))
end += 1
elif number == "6":
total += roll
outcome = total + modifier
print("Dice roll: " + str(total) + "+" + str(modifier) + " = " + str(outcome))
end += 1
elif number == "7":
run = False
```

Anyone know how i can get this to 1) have 7 still exit the program as it should as well as just give me 1 answer instead of number of dices rolled answers?

Below is what i mean by number of dices rolled answers:

Enter number of choice here: 1

Enter number of dice being rolled: 2

How much to modify the roll by?2

Dice roll: 15+2 = 17

Dice roll: 22+2 = 24