I have a file which has lines like below, Files are in /tmp/file
cat /tmp/file
server1,server2
server4,server4
I want to concatenate each line to new word ".com" so it will look like below. When i covert this and split it doesn't work , Please guide
newfile = server1.com,server2.com
server3.com,server4.com
with open('/tmp/file', 'r') as file1:
newline = ''
for line in file1:
y = line.split()
print(y)
for line in y:
z = str(y).split(',')
print(z)
newline = str(z)+".com".join('' )
print(newline)
Results :
['server1,server2']
['server3,server4']
["['server3", "server4']"]
["['server3", "server4']"]
Expected : server1.com,server2.com server3.com,server4.com
','.join([f"{j}.com" for i in p.read_text().splitlines() for j in i.split(',')])(wherepispathlib.Pathobject.)