/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
from random import * for x in range(10): print random() print '=============================' z = ['ciao', 'piccolo', 'bambino', 'sono', 'qua', 'io', 'in verita'] for x in z: # picks a random el from a list print choice(z) print '=============================' # "Two ways to randomly attach elements" for x in range(10): shuffle(z) # shuffle modifies the element in place so you have to call it beforehand print " ".join(z) # an alternative method print '=============================' for x in range(10): print " ".join(sample(z, len(z)))