I am still a beginner, but I want to read a file once, do processing, then write to the file. the read code is:
What is wrong with the read code?
f = open("test3.txt", "w") with open("test3.txt", "r") as opened_file: for line in opened_file: MS, StartYear, YourStartAge, HerStartAge, Exempt, BFedItmDed, FedItmDedYrs, State, LivExp, Inflation, Inf1, Inf2, Inf3, Inf4, Inf5, Inf6, Inf7, Inf8, Inf9, Inf10, TESTPcnt, TESTYr, TFISTPcnt, TFISTYr, TFESTPcnt, TFESTYr, TFFISTPcnt, TFFISTYr, TDESTPcnt, TDESTYr, TDFISTPcnt, TDFISTYr, BTE, BTFI, BTC, TERtn, TFIRtn, TCRtn, BTFE, BTFFI, BTFC, TFERtn, TFFIRtn, TFCRtn, BTDE, BTDFI, BTDC, TDERtn, TDFIRtn, TDCRtn, YourJob, SpJob, YourRetInc, SpRetInc, YourSSInc62, YourSSIncFRA, YourSSInc70, SpSSInc62, SpSSIncFRA, SpSSInc70, YourRetAge, SpRetAge, YouBgnRetIncAge, SpBgnRetIncAge, YouSSStartAge, SpSSStartAge, IraStartAge, IraEndAge, IraRequest = line.split()to write the file, I have this code:
f.write('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}' '{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}' '{} {} {} {} {} {} {} {} {} {} {} {} {}' .format(MS, StartYear, YourStartAge, HerStartAge, Exempt, BFedItmDed, FedItmDedYrs, State, LivExp, Inflation, Inf1, Inf2, Inf3, Inf4, Inf5, Inf6, Inf7, Inf8, Inf9, Inf10, TESTPcnt, TESTYr, TFISTPcnt, TFISTYr, TFESTPcnt, TFESTYr, TFFISTPcnt, TFFISTYr, TDESTPcnt, TDESTYr, TDFISTPcnt, TDFISTYr, BTE, BTFI, BTC, TERtn, TFIRtn, TCRtn, BTFE, BTFFI, BTFC, TFERtn, TFFIRtn, TFCRtn, BTDE, BTDFI, BTDC, TDERtn, TDFIRtn, TDCRtn, YourJob, SpJob, YourRetInc, SpRetInc, YourSSInc62, YourSSIncFRA, YourSSInc70, SpSSInc62, SpSSIncFRA, SpSSInc70, YourRetAge, SpRetAge, YouBgnRetIncAge, SpBgnRetIncAge, YouSSStartAge, SpSSStartAge, IraStartAge, IraEndAge, IraRequest)) f.close()My PyCharm IDE says the "read" code (highlighting the variables) has no effect.
What is wrong with the read code?