How to make equal space between words - python
<p>(SORRY FOR BAD ENGLISH)
Im working at cmd.
I want to do that thing:</p>

<pre><code>file_name              DIR
file_name_3            DIR
file_name_545          DIR
file_name_LlK          DIR
</code></pre>

<p>Instead of doing that thing:</p>

<pre><code>file_name          DIR
file_name_3          DIR
file_name_545          DIR
file_name_LlK          DIR
</code></pre>

<p>I tryied to do this in loop:</p>

<pre><code>print data.ljust((20 - len(data) + 20)) if len(data) &lt;= 20 else (data[0:17] + '...').ljust(20)), 'DIR'
</code></pre>

<p>But that thing not working becase there are letters bigger then another, then 'ljust' the words makes it not possible.</p>

<p>First, find the widest point in your data.  I assume you have a list of tuples.</p>

<pre><code>col_width = max(tup[0] for tup in list_of_tuples)
for tup in list_of_tuples:
    print(tup[0].ljust(col_width), tup[1].ljust(colwidth))
</code></pre>

<p><code>ljust</code> is the function you want, but I think you are setting the columns on different lines to different widths, which is not what you want.</p>

python