Is there a random function in python that accepts variables? -
I'm trying to make a simple dice roller, and I want to make it a random number between 1 and number However, the randink
will not accept a variable, is there a way to do what I am trying to do?
Code given below:
import a = 0food = 0 work = 0 sides = input ("how many dice do you want to roll?") While one & Lt; = Side: A = A + 1 work = random Print (1, 4) Final = Last + Job Print "Your total is:", last
It seems that you are confused about the number of dice and the number of sides
I have changed the code to use the raw_input ()
. Input ()
is not recommended because Python literally evaluates user input which can be a malicious python code
import a = 0final = 0 work = 0 rolls = int (Raw_input ("How many dice you want to roll?")) Side = int (raw_input ("how many sides?"), Whereas a & lt; Roll: a = a + 1 work = random.randint (1, side) final = final + printing print "your total is:", last
Comments
Post a Comment