[Tutor] loop print issue

ose micah osaosemwe at yahoo.com
Fri Oct 11 11:00:05 EDT 2019


 Hello Alan,
I need your quick help, I am same loop print issue you pointed out.I have a file "xlist_file" with a list of varying values of up to 70. from this file I intend to split the content to two different files output1.txt and output2.txt. I want this values to be always fresh, making use of w+ and no appending. currently if I switch  +a to +w in the output2.txt, it always cleans out the values.

"line of code:"
sys.stdout = open('output1.txt','w+')
for i in xlist_file:        if counter < 36:            if counter >= 35:                sys.stdout.close()                sys.stdout = open('output2.txt','a+')                print(i)                counter +=1            else:                print(i)                counter +=1sys.stdout.close()

content of xlist_file
1541091716262537365049......
is there a way I can go about this issue? I really value your input.
Thanks

Ose Micah.


More information about the Tutor mailing list