Apr-09-2024, 06:18 PM
(This post was last modified: Apr-09-2024, 06:30 PM by Gribouillis.)
The two early print statements print but the print statements inside the for loop not. Please advise how to correct my code so the for loop works
datacompletefile = open("c:/temp/completefile.txt", "w") datafinalfile = open("C:/temp/attempt2_final3.txt", "r") datafinalreader = datafinalfile.readlines() print("in complete area") print("xxx") for datafinalline in datafinalreader : print("datafinalline = ", datafinalline) finaltokens = datafinalline.split() finalindex = finaltokens[0] print('finalindex = ', finalindex) for i in alllist : if i == [finalindex] : print("IN") datacompletefile.write(datafinalline) datacompletefile.write("\n") else : print("NOT IN") allcomplete = i + ' 0 0' datacompletefile.write(allcomplete) datacompletefile.write("\n") datacompletefile.close datafinalfile.close
Gribouillis write Apr-09-2024, 06:30 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.