Jul-17-2020, 08:40 PM
import time global list list = [] #####This is not the final list, but a list where you add everything to be sorted def add_to_list(): #####This should loop until you decide you are ready print("Artist: Album (or type \"done\" if you have finished the list)") add = input() if add == "done": finalize_list() else: list.append(add + "/n /n") add_to_list() def finalize_list(): list_sorted = list.sort() ####This list should be alphabetical list_final = str(list_sorted) ####This should convert the list to a string due to an earlier error file = open("LP_list.txt", "w+") file.write(list_final) file.close() print("List is now in the text file.") time.sleep(3) exit() ####Actual add_to_list()This code writes "None" (without the quotation marks) into the file.
My objective is to first write something, hit enter, append it to the list, then sort the list out alphabetically and then write it into a .txt file.