Skip to content

Instantly share code, notes, and snippets.

@luisenriquecorona
Created February 10, 2020 21:39
Show Gist options
  • Save luisenriquecorona/59d0ad6bdcac85f843d409cd4bdbb076 to your computer and use it in GitHub Desktop.
Save luisenriquecorona/59d0ad6bdcac85f843d409cd4bdbb076 to your computer and use it in GitHub Desktop.
This module can also choose an item at random from a sequence, and shuffle a list of items randomly.
>>> random.choice(['Life of Brian', 'Holy Grail', 'Meaning of Life'])
'Holy Grail'
>>> random.choice(['Life of Brian', 'Holy Grail', 'Meaning of Life'])
'Life of Brian'
>>> suits = ['hearts', 'clubs', 'diamonds', 'spades']
>>> random.shuffle(suits)
>>> suits
['spades', 'hearts', 'diamonds', 'clubs']
>>> random.shuffle(suits)
>>> suits
['clubs', 'diamonds', 'hearts', 'spades']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment