How can I print a string depending on the list value?
<p>I want to print a string depending on the values in the list. Values can be 0 or 1. For example:</p>

<pre><code># Example [a,b,c] = [0,0,1] -- &gt; print str c
# [1,0,1] -- print str a and str c

index_list = [0,0,1] # Example      
str_a = "str_a"
str_b = "str_b"
str_c = "str_c"

print str
</code></pre>

<pre><code>&gt;&gt;&gt; a = [str_a,str_b,str_c]
&gt;&gt;&gt; b=  [0,0,1]
&gt;&gt;&gt; ','.join(i for i,j in zip(a,b) if j)
'str_c'
</code></pre>

python python-2.7