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?
#1
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 ,
Reply
#2
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
Reply
#3
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
Reply
#4
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  coma separator is printed on a new line for some reason tester_V 4 417 Feb-02-2024, 06:06 PM
Last Post: tester_V
  Python rule about the space character surrounding the equal sign ineuw 10 1,514 Sep-21-2023, 09:17 AM
Last Post: ineuw
  How do I handle escape character in parameter arguments in Python? JKR 6 1,035 Sep-12-2023, 03:00 AM
Last Post: Apoed2023
  Removing Space between variable and string in Python coder_sw99 6 6,123 Aug-23-2022, 01:15 PM
Last Post: louries
  Remove a space between a string and variable in print sie 5 1,705 Jul-27-2022, 02:36 PM
Last Post: deanhystad
  [solved] unexpected character after line continuation character paul18fr 4 3,290 Jun-22-2021, 03:22 PM
Last Post: deanhystad
  python error: bad character range \|-t at position 12 faustineaiden 0 3,642 May-28-2021, 09:38 AM
Last Post: faustineaiden
  Reducing JSON character count in Python for a Twitter Bot johnmitchell85 2 45,630 Apr-28-2021, 06:08 PM
Last Post: johnmitchell85
  Why doesn't this print statement work? stylingpat 10 5,585 Mar-23-2021, 07:54 PM
Last Post: buran
  Undesired space after using \n in print Tuxedo 4 2,720 Mar-03-2021, 10:16 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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