python - i want to create a function to roll a set number of dice thru the num variable in pythonic way -
my question how list roll print 6 numbers?
import random random import * num = 6 def d6(num): x in range(num): roll = randint(1,6) print ("", roll) print("finished rolled: ",roll)
you can append each roll array, , print array.
import random random import * num = 6 def d6(num): rolls = [] x in range(num): rolls.append(randint(1,6)) print rolls >>> d6(5) [4, 6, 1, 1, 1]
`
python list function random numbers
No comments:
Post a Comment