dimanche 16 juin 2019

Why does the variable d1 in a function give the error "d1 is not defined" (it was working but now it's not)

'''This is the version of a dice-roll I came up with. I know I am not that smart, and rather slow minded. But I am trying learn and make this code work. The variable d1 is getting the error "d1 is not defined", which stops the roll.'''

import numpy as np
import pandas as pd
import random
from statistics import mean, stdev

def dice():
    count = 0
    d1=([random.randint(1,6) for _ in range(10)])
    count = count + d1  
    d2=([random.randint(1,6) for _ in range(10)])
    count = count + d2

    tot=(d1+d2)
    medi=mean(d1,d2)
    stand=stdev(d1,d2)

print(d1,d2) print(tot) print(medi) print(stand)




Aucun commentaire:

Enregistrer un commentaire