0

I am trying to make a dice and I want to make it so when a certain number is rolled It will add 1 to a variable. How would I do this?

This is what I tried and it did bot work y=0 z=0 def d6(x): import random for i in range(x): value=random.randint(1,6) if value==1: y+=1 if value==2: z+= d6(1)

22nd Aug 2016, 4:41 PM
Ezie
1 Antwort
+ 1
first, you should not import inside functions, do it at the beginning of script. second, there might be something wrong with indents. try this: import random y = 0 z = 0 def d6(x): for i in range(x): value = random.randint(1, 6) if value == 1: y += 1 if value == 2: z += 1 d6(1) Also, you might not see if y or z is different without any other actions, like print() etc.
22nd Aug 2016, 7:15 PM
Demeth
Demeth - avatar