So basically, I have a super long output, and I want to be able to save this output to a brand new text file, without changing my old file. This is my code thus far, I basically just need to know what to do with my out_file variable.
Thanks for all the future help.
txt_list = [] with open("X:\- Photogrammetry\Python to Correct DXF Colors\InvolvedPontiac.dxf", "r") as in_file, open("X:\- Photogrammetry\Python to Correct DXF Colors\InvolvedPontiacfixed.txt", "w+") as new_file: for line in in_file: line = line.rstrip() txt_list.append(line) Entity = 0 i = 0 while i < len(txt_list): if txt_list[i] == "ENTITIES": Entity = 1 if txt_list[i] == " 62" and Entity == 1: txt_list[i+1] = " 256" i += 1 Layer = 0 j = 0 while j < len(txt_list): if txt_list[j] == "LAYER" and txt_list[j+2] != " 7": Userinput = input("What color would you like for the layer " +txt_list[j+2] + "? Type 0 for black, 1 for red, 3 for green, 4 for light blue, 5 for blue, 6 for magenta, 7 for white, 8 for dark grey, 9 for medium gray, or 30 for orange.") txt_list[j+6] = " " + Userinput print ("The " + txt_list[j+2] + " layer now has a color code of " + Userinput) j += 1 for item in txt_list: new_file.write(item) print ('\n'.join(txt_list))