Dec-27-2020, 07:16 PM
Hello,
I have this txt file. (The length is 15000)
And according to input, I want to separate my numbers as different lines and each line will have equal size
For instance, suppose that i is the input and i =10
then my text file will become like that:
The code should be something like that
But I couldn't complete it
Can you please help me?
Best
I have this txt file. (The length is 15000)
1010100101010110000000000001111111111
And according to input, I want to separate my numbers as different lines and each line will have equal size
For instance, suppose that i is the input and i =10
then my text file will become like that:
1010100101
0101011000
0000000000
...The code should be something like that
1 2 3 4 5 6 7 8 9 10 |
with open ( "names.txt" , "r" ) as f: input_list = f.read() def write_len(input_list): final_str = "\n" .join([ str ( len (item)) for item in input_list]) with open ( "name_length.txt" , "w" ) as w: w.write(final_str) return 1 |
Can you please help me?
Best