Skip to content

Instantly share code, notes, and snippets.

@mike-pete
Last active December 1, 2019 07:22
Show Gist options
  • Save mike-pete/95cf531fb82ccf9efc0ad468024c223b to your computer and use it in GitHub Desktop.
Save mike-pete/95cf531fb82ccf9efc0ad468024c223b to your computer and use it in GitHub Desktop.
This Python script lets you quickly roll stats for a new D&D character.
from random import randint
# roll 4 d6 and drop the losest val
def rollStat():
rolls = []
for i in range(4):
rolls.append(randint(1, 6))
rolls.sort(reverse=True)
topThree = rolls[0:3]
print(' + '.join(str(x) for x in topThree) + ' = ' + str(sum(topThree)))
for i in range(6):
rollStat()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment