Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Roll a die, defaulting to d6
import random
def roll(d=6):
return random.randint(1, d)
# Randomly select a value a list
import random
wordlist = ['quick', 'brown', 'fox', 'jumped']
random.choice(wordlist)
# To randomly sort a list:
import random
mystr = ['a','b','c','d','e','f','g','h']
random.shuffle(mystr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment