title: how to print in single line with an inline if else statement in python 2.7
body: <p>I am using python2.7. The below code works if I remove <code>,</code> in the print statement.
  but that prints the values in different lines. I want to print in same line with an inline <code>if-statement</code> if possible.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>def binary(x):
  
     for i in [128,64,32,16,8,4,2,1]:
        #if x&amp;i: print 1,
        #else: print 0,
         print 1, if x&amp;i else 0
  
  binary(127)
  </code></pre>
  
  <p>It throws the following syntax error:</p>
  
  <pre><code>File "binary.py", line 6
      print 1, if x&amp;i else 0
                ^
  SyntaxError: invalid syntax
  </code></pre>