import os import random if not os.path.exists("musiclist.txt"): print("musiclist.txt not found") exit() if os.path.exists("musiclist.html"): if os.path.exists("musiclist.html.old"): input("musiclist.html and musiclist.html.old already exists. Press Enter to overwrite musiclist.html.old or Ctrl+C to exit") os.remove("musiclist.html.old") os.rename("musiclist.html", "musiclist.html.old") with open("musiclist.txt", "r") as f: musiclist = f.readlines() html = "\n\n
\n\n\n\n\n" random.shuffle(musiclist) html += "