lunedì 19 luglio 2010

Jokes with Python... 99 bottles of beer

una piccola funzione Python, un pò di divertimento :P
def ManyBottlesOfBeer(bottles):
for i in reversed(xrange(1, bottles+1)):
print " ".join([str(i), "bottles" if i!=1 else "bottle" , "of beer on the wall"])
print " ".join([str(i), "bottles" if i!=1 else "bottle", "of beer"])
print " ".join(["Take one down, pass it around,\n", str(i-1) if i-1 else "no more", "bottles" if i!=1 else "bottle", "of beer on the wall\n"])
print "go to the store, \nbuy sone more, \n", bottles," bottles of beer on the wall!"


divertitevi con
>>>ManyBottlesOfBeer(99) #a little joke xD

Stay Tuned!!!

0 commenti:

Posta un commento