Skip to content

Instantly share code, notes, and snippets.

@bogardpd
Last active June 12, 2020 16:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogardpd/c584b8776de56319e1bad6798f7c1543 to your computer and use it in GitHub Desktop.
Save bogardpd/c584b8776de56319e1bad6798f7c1543 to your computer and use it in GitHub Desktop.
output = ""
bottles = 99
def bottle_str(bottles):
if bottles == 0:
return "No bottles"
elif bottles == 1:
return "1 bottle"
else:
return f"{bottles} bottles"
while bottles > 0:
output += f"{bottle_str(bottles)} of beer on the wall\n"
output += f"{bottle_str(bottles)} of beer\n"
output += f"Take one down, pass it around\n"
bottles = bottles - 1
output += f"{bottle_str(bottles)} of beer on the wall\n\n"
f = open("99-bottles.txt", "w")
f.write(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment