I am a beginner programer, and I have to create a program that simulates rolling a dice 10000 times, and then tells the user how many times they rolled each number. The hard part is, I have to do it using only two variables.
import random
count1=0
count2=0
count3=0
count4=0
count5=0
count6=0
dice=random.randint(1,7)
for i in range(10000):
if dice==1:
count1+=1
if dice==2:
count2+=1
if dice==3:
count3+=1
if dice==4:
count4+=1
if dice==5:
count5+=1
if dice==6:
count6+=1
print "You entered "+ str(count1)+ " ones, " + str(count2) + " twos, "+str(count3) + " threes, " +str(count4)+ " fours, " +str(count5)+ " fives, and "+str(count6) +" sixes."
The problem is, I can't get the program to pick more than one random number, it will just repeat the same number 10000 times. Also, as you can see, I have no idea how to write this program with only two variables, but I think it may have something to do with lists.
You need to put the line
dice=random.randint(1,7)
inside the for loop.