randomly.py

>>> 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']
This module can also choose an item at random from a sequence, and shuffle a list of items randomly.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.