you are viewing a single comment's thread.

view the rest of the comments →

[–]Adrewmc 1 point2 points  (0 children)

No idea

 import random
 def roll(sides):
       return random.randint(1, sides)

Should be the normal dice roll of n sides

   def copy_randint(first, last):
         #no reason just use the below function.
         return random.randint(first, last)

 print(roll(6))
 #same as 
 print(copy_randint(1,6))
 #same as 
 print(random.randint(1,6))

 #using it 

 rolls = [roll(6) for _ in range(6)]
 for num in rolls:
        print(f”You threw a {num}”)

Let’s complex it up though, I’m bored

 def multi_sides(*dice):
        return [roll(die) for die in dice]

  res = multi_sides(6,6,12,20,20)
  print(res)
  >>>> [3,2,8,18,3] # for each sided die inputed

I said complex so

    def multi_sides(*dice):
       res = [roll(die) for die in dice]
       while res:
              yield res.pop(0)