Created
February 10, 2020 21:39
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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