Using random library functions in my own functions python 3 -
Why can not I use RudraZ this function? Random print (random.randrange (0,4) def defaults (dice): dice_one = random.randrange (1,3) return (dice_one) print (random (4)) import random print
this error is
line 6, error in random dice_one = random.randrange (1,3) attribute: 'function' object has no attribute 'any Also thanks for the help
Python thinks you 're the name of the random module as you name it Since your own Field trying to call a method of random function. Change the name of your function something else and it should be fine.
def chance (dice): dice_one = random.randrange (1,3) return dice_one print (chance (4)) Also, ensure It is not that you are trying to do with 'dice' logic if it is for the number of sides on the die, then try:
def chance (dice): dice_one = Random.randrange (1, dice) return dice_one
Comments
Post a Comment