'''A more interesting way to get the lyrics to "99 Bottles of Beer on the Wall", in Python. Is this considered cheating? Adapted from http://99-bottles-of-beer.net/language-python-931.html''' import re, urllib lines = urllib.URLopener().open('http://www.99-bottles-of-beer.net/lyrics.html').readlines() doprint=False for l in lines : lines2 = re.sub('
', '', re.sub('|
|
','\n', re.sub('No', '\nNo',l.strip())))
for l2 in lines2.split('\n'):
if l2.startswith('99 bottles') :
doprint=True
if l2.startswith('Go to the store') :
doprint=False
if doprint :
print l2