D&D dice roll python
<p>Trying to roll dice like in dungeons and dragon but display each roll. I dont quite know what im doing wrong and appreciate all the help.</p>

<pre><code>from random import randint
def d(y): #basic die roll
    return randint(1, y)
def die(x, y): #multiple die roll 2d20 could roll 13 and 7 being 20 
    for [x*d(y)]:
        print (sum(int(y)))

print (die(3, 20))
</code></pre>

<p>ok so i took the advice and changed it but still recieving an error on my return line</p>

<pre><code>#
#trying to roll dice like in dungeons and dragon but display each roll
from random import randint 
def d(sides): 
    return randint(1, sides) 
def roll(n, sides): 
    return tuple(d(sides) for _ in range(n))
def dice(n, sides):
    print (roll(n, sides))
    return sum(dice)
print(dice(3,20))
</code></pre>

<p>You can't just multiple the result of a single call to <code>d()</code>, you need to make <code>n</code> different calls to the <code>d()</code>:</p>

<pre><code>from random import randint

def d(sides):
    return randint(1, sides)

def roll(n, sides):
    return tuple(d(sides) for _ in range(n))

dice = roll(3, 20)
print(dice, sum(dice))
# (20, 18, 1) 39
</code></pre>

python python-3.x dice