Print string without a certain word?
<p>So, if I have code like this:</p>

<pre><code>a = ["a", "b", "c", "null"] 

print a
</code></pre>

<p>The number of <code>"null"</code>s varies in the output quite a lot for some reason.
How could I print <code>a</code> without the <code>"null"</code>?</p>

<p>I get the impression that you wish to convert the list to a string with a function and display each data element on a separate line without null being included.  So, here's what I suggest:</p>

<pre><code># remove null and convert list to string with function  
# and display results on separate lines

a = ["a", "b", "c", "null"] 

def str(A): 
    a = [data for data in A if data != "null"]
    aSTR = '\n'.join(a)
    return aSTR

print str(a)
</code></pre>

<p>Run code <a href="http://www.tutorialspoint.com/execute_python_online.php?PID=0Bw_CjBb95KQMRllvRExHa3pjM2M" rel="nofollow">here</a></p>

python python-2.7 printing