How can I print text file side by side in python?
<p>I edited "how can I print for loops side by side in python?".</p>

<p>I tried to figure out how to print side by side of my program.</p>

<p>What I want to do is to read each file line by line, and print side by side in final.</p>

<p>There are two problems in my program.</p>

<p>First, text file shows up differently as I expected.</p>

<pre><code>The original 'num.text':         My expectation:       The result I got:

0000                             1111                      1
0000                             1111                      1
2222                             2222                      2222
2222                             2222                      2222
</code></pre>

<p>Second, I don't know how to change my program to print side by side (result1 and result2). I tried 'main def(): print(result1+result2)', but it did not show anything. </p>

<pre><code> num.txt     num2.txt      -&gt;  Print should be:
 0000        2222              1111  2222
 0000        2222              1111  2222
 2222        0000              2222  3333
 2222        0000              2222  3333
</code></pre>

<p>Here is my program. It's pretty messed up now.</p>

<pre><code>def file1():

    f=open("num.txt", "r")

    for line in f:
        for i in range(len(f)):
            l_line = str(f).strip("[]") 
            result1 = (l_line.replace('0','1'))
        print(result1)
file1()

def file2():

    f=open("num2.txt", "r")   
    for line in f:
        for i in range(len(f)):
            data_line = str(f).strip("[]") 
            result2 = (data_line.replace('0','3'))
        print(result2)
file2()
</code></pre>

<p>So, can someone help me to solve these problems?
It would be nice for me if you explain as you can.</p>

<p>Anyway, thank you for all of the comments and codes below.</p>