Shiva Nandam Shiva Nandam - 4 years ago 92
Python Question

How to omit newlines in Python?

I know..... one way to omitting new lines in Python with concatenation:

a = 'strin'
b = 2
print str(b)+a


how many ways we can this be done?

Answer Source

Yes finally I found the answer.
We can omit newlines in 3:

  1. "+" (Concatenation)
    Ex:

    a = sachin
    b = 'tendulkar' 
    a += b 
    print(a)
    
  2. By using "," (comma) see above answers

  3. By using write() function:

    import sys
    write = sys.stdout.write
    write('20)
    write('17')
    

    Output:

    2017
    

    The write() method does not add a newline character ('\n') to the end of the string.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download