'How do I split or join 2d array printed list with word 'is'?

I have tried append, 'is'.join, .split('is'), .replace, sep='' and my results look like this.

0is0is0is0is is5is0is.is0is

is0is0is0is1is is6is7is.is5is

array.txt file

0000 50.0

0001 67.5

0002 76.5

Expected Result

0000 is 50.0

What I have so far.

fo = open("array.txt")

line = fo.read()

for line in fo:

 line = line.split()

 line = [[0 for i in range (cols)] for j in range(rows)]

for row in line:

 print (line)

 break```
          
      


Solution 1:[1]

Open the file, remove the \n from each line using .rstrip(), split the space using .split(maxsplit=1), and join the two parts together using " is ".join(...):

with open("arrary.txt") as data:
   for line in data:
     print(" is ".join(line.rstrip().split(maxsplit=1)))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bharel