10 green bottles assignment
A good place to start is to break your big main method into smaller chunks of work. Then you can focus on improving the code in each section.

Currently your main method does many things, it reads user input, builds up a song and writes it to a file. Here's how you might rewrite it:

def main():
  num_bottles = get_num_bottles_from_user()
  hue = get_hue_from_user()
  song = build_song(num_bottles, hue)
  out_filename = create_out_filename(num_bottles, hue) 
  write_song_to_file(song, out_filename)


The function is easier to read if all the calls it makes are at a similar level of abstraction. The main method doesn't do low level operations like input reading or file writing, it tells a story.