python - I need to print this 20 times -
so have code here prints random shakespearean insult through 3 lists. submit code, have print 20 insults , know there faster way writing final print statement 20 times. remedial can't remember how it. here's code guys:
import random list1 = ["artless", "bawdy", "bootless", "churlish", "clouted"] list2 = ["base-court", "bat-fowling", "beetle-headed", "clay-brained" ] list3 = ["apple-john", "baggage", "bladder", "boar-pig", "coxcomb"] def nurd1(): return (random.choice(list1)) def nurd2(): return (random.choice(list2)) def nurd3(): return (random.choice(list3)) print ("thou" + " " + nurd1() + " " + nurd2() + " " + nurd3() )
import random words = [ ["thou"], ["artless", "bawdy", "bootless", "churlish", "clouted"], ["base-court", "bat-fowling", "beetle-headed", "clay-brained" ], ["apple-john", "baggage", "bladder", "boar-pig", "coxcomb"] ] print(*(' '.join([random.choice(l) l in words]) r in range(20)), sep='\n')
Comments
Post a Comment