I have a text file like this:
abc123bvjhfvb:dlnvsl|smth
fsbffsb378hbdcbs:v5v3v|smth
sdcg87wgn8:vy5b4|smth
sin87s88vnus:y54545v4v|smth
rc8n782c:efghrn|smth
As you can see there is a space starting from the second line.
How can I convert these lines to these?
abc123bvjhfvb:dlnvsl
fsbffsb378hbdcbs:v5v3v
sdcg87wgn8:vy5b4
sin87s88vnus:y54545v4v
rc8n782c:efghrn
I tried something like this:
lines = open("file.txt").readlines()
for x in lines:
x.strip(" ").split("|")
print (x[0])
But it prints only the "a" of abc123 and then a series of space for each line. I think the [0] goes to print the first letter instead of printing the first part of split before the "|" (for example abc123bvjhfvb:dlnvsl)