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? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

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, 3:25 PM
Ezie
3 Answers
+ 1
list =[1,2,3,4,5,6] rolled_no = random.choice(list) print (rolled_no+1) Sorry if i got ur question wrong😐
22nd Aug 2016, 3:37 PM
Surya Deep Mishra
Surya Deep Mishra - avatar
0
I am actually just trying to add 1 to a variable, not print it and I want when I roll a 4 for example it add 1 to a variable like x Thanks for answering though
22nd Aug 2016, 3:47 PM
Ezie
0
what does (spam* eggs)=
14th Jan 2017, 3:38 PM
Adam Neis
Adam Neis - avatar