Skip to content

Instantly share code, notes, and snippets.

@packetchef
Created August 1, 2020 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save packetchef/64b9f4e400d88ded83a1d330b7c37b15 to your computer and use it in GitHub Desktop.
Save packetchef/64b9f4e400d88ded83a1d330b7c37b15 to your computer and use it in GitHub Desktop.
# 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