Python Forum
how to add a coma in print statement of python without preceding space character?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to add a coma in print statement of python without preceding space character?
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?


name = "Andrew"
print name,","


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
>>> sys.version_info.minor
Not less than.
>>> sys.version_info.major
>>> sys.version_info.minor - 1
(Sep-27-2018, 08:05 PM)brittocj Wrote: print name,","
You're using python2, which is very close to it's end of life:
Python 3 has been out for slightly less than 10 years now.

Possibly Related Threads…
Thread Author Replies Views Last Post
  from global space to local space Skaperen 4 415 Sep-08-2020, 04:59 PM
Last Post: Skaperen
  Runs perfect in Python but fails to print last statement when converted to .exe. Help sunil422 3 260 Aug-13-2020, 01:22 PM
Last Post: deanhystad
  SyntaxError: unexpected character after line continuation character siteshkumar 2 309 Jul-13-2020, 07:05 PM
Last Post: snippsat
  Taking brackets out of list in print statement pythonprogrammer 3 544 Apr-13-2020, 12:25 PM
Last Post: perfringo
  Help ANSI character and python... sid4g 2 402 Mar-19-2020, 06:08 PM
Last Post: sid4g
  capture print statement written in Stored Procedure in SQL Server brijeshkumar_77 0 477 Feb-18-2020, 03:22 AM
Last Post: brijeshkumar_77
  printing a list contents without brackets in a print statement paracelx 1 441 Feb-15-2020, 02:15 AM
Last Post: Larz60+
  how can i handle "expected a character " type error , when I input no character vivekagrey 2 547 Jan-05-2020, 11:50 AM
Last Post: vivekagrey
  How to recognize space or enter as one-character input? Mark17 5 564 Oct-17-2019, 08:19 PM
Last Post: jefsummers
  Embedding return in a print statement Tapster 3 454 Oct-07-2019, 03:10 PM
Last Post: Tapster

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020