Python Forum

Full Version: how to add a coma in print statement of python without preceding space character?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am new to python and learning,in print statement a space character is injected in before the comma, which is undesirable. How may we print the comma immediately after name like Andrew, with no intervening space character?

Code:

name = "Andrew"
print name,","

Output:

Andrew ,
print name+","
You should always state what version of python you are using. In this case I assume it is Python2.X
import sys
print sys.version_info
To show something that will not work for you.
>>> name = "Andrew"
>>> print(f'{name} ,')
Andrew ,
We are clear in advice what new user should use.
To take in hint form.
>>> import sys
>>> 
>>> sys.version_info.major
3
>>> sys.version_info.minor
7
Not less than.
>>> sys.version_info.major
3
>>> sys.version_info.minor - 1
6
(Sep-27-2018, 08:05 PM)brittocj Wrote: [ -> ]print name,","
You're using python2, which is very close to it's end of life: https://pythonclock.org/
Python 3 has been out for slightly less than 10 years now.