Issue
# Imports
import random
import time as t
# Lists
D=[1,2,3,4,5,6]
# Varibles
dr=0
total=0
# Defines the amount of total of the dice
def rp(num):
for r in range(num):
dr+1
DR=random.choice(D)
total=+1
print('Die', dr, 'is', DR ,end = '. ')
How do I get dr, to increase every time this code runs. I've tryed everything, also, don't blame me if this looks like a repost. It's my second time using this.
for r in range(num):
dr+1
DR=random.choice(D)
total=+1
print('Die', dr, 'is', DR ,end = '. ')
Solution
I assume you want your program to generate num
die throws each time you run it. Your code looks quite immature(not a discouragement) so I assume you are still learning. Kudos.
You can use this:
import random
def throwDies(num):
for c in range(num):
throw = random.randint(1,6) #gets a random number between 1 and 6 inclusive
print("Throw number %d is #%d"%(c,throw))
x = int(input("Enter the number of throws to make: "))
throwDies(x)
Answered By - NGY
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.