How to add some data where ever a empty line is present.
for ex. between line 3 and line 4 below, we have a empty line and I want to add some stuff at that empty line location.
how can i do it please help me. I am new to python.
line 1
line 2
line 3

line 4
line 5

The data is present in a file n I have to write back the data to the same file without damaging the original file

You could load the data into an array and loop through to find any empty strings. Or read the file line by line and use an "if" statement to find any empty lines.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.