Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8624357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:30:39+00:00 2026-06-12T07:30:39+00:00

I’m new to Python, and I’m wondering how to print multiple values without having

  • 0

I’m new to Python, and I’m wondering how to print multiple values without having the extra space added in between. I want the output ab rather than a b without having to call print twice:

print("a", end="")
print("b")

Also, I have the following code:

a = 42
b = 84 

and I want to print their values as a = 42, b = 84, yet if I do

print("a = ", a, ", ", b = ", b)

extra spaces are added (it outputs a = 42 , b = 84)

Whereas the Java style,

print("a = " + a + ", b = " + b)

raises a TypeError.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:30:41+00:00Added an answer on June 12, 2026 at 7:30 am

    You can use the sep parameter to get rid of the spaces:

    >>> print("a","b","c")
    a b c
    >>> print("a","b","c",sep="")
    abc
    

    I don’t know what you mean by “Java style”; in Python you can’t add strings to (say) integers that way, although if a and b are strings it’ll work. You have several other options, of course:

    >>> print("a = ", a, ", b = ", b, sep="") 
    a = 2, b = 3
    >>> print("a = " + str(a) + ", b = " + str(b))
    a = 2, b = 3
    >>> print("a = {}, b = {}".format(a,b))
    a = 2, b = 3
    >>> print(f"a = {a}, b = {b}")
    a = 2, b = 3
    

    The last one requires Python 3.6 or later. For earlier versions, you can simulate the same effect (although I don’t recommend this in general, it comes in handy sometimes and there’s no point pretending otherwise):

    >>> print("a = {a}, b = {b}".format(**locals()))
    a = 2, b = 3
    >>> print("b = {b}, a = {a}".format(**locals()))
    b = 3, a = 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I want to show the soap response to UIWebview.. my soap response is, <p><img

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.