Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14271

I want to split a file in my text file based on arguments I pass. While doing so, I get extra empty string at the end

$
0
0

I'm reading a text file and splitting the sentence into a list based on arguments I pass. Splitting the data is working file. But at the end I get an empty string. How can I avoid that

def duplicate(input): emp = [] with open(input, 'r') as file: for item in file: value = item.strip().split('.') emp.extend(value) return emp

This is the python code I used to split. The argument is '.' . But at the end I am getting an empty string. 'this is commonly referred to as the “application factory” pattern', ''. Is there any other way to avoid this empty string at the end.


Viewing all articles
Browse latest Browse all 14271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>