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 8162557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:45:24+00:00 2026-06-06T18:45:24+00:00

When I use the print command, it prints whatever I want and then goes

  • 0

When I use the print command, it prints whatever I want and then goes to a different line. For example:

print "this should be"; print "on the same line"

Should return:

this should be on the same line

but instead returns:

this should be
on the same line

More precisely I was trying to create a program with if that told me whether a number was a 2 or not

def test2(x):
    if x == 2:
        print "Yeah bro, that's tottaly a two"
    else:
        print "Nope, that is not a two. That is a (x)"

But it doesn’t recognise the last (x) as the value entered, and rather prints exactly: "(x)" (the letter with the brackets). To make it work I have to write:

print "Nope, that is not a two. That is a"; print (x)

And if e.g. I enter test2(3) that gives:

Nope, that is not a two, that is a
3

So either I need to make Python recognise my (x) inside a print line as the number; or to print two separate things but on the same line.

IMPORTANT NOTE: I am using version 2.5.4

Another note: If I put print "Thing" , print "Thing2" it says "Syntax error" on the 2nd print.

  • 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-06T18:45:26+00:00Added an answer on June 6, 2026 at 6:45 pm

    In Python 3.x, you can use the end argument to the print() function to prevent a newline character from being printed:

    print("Nope, that is not a two. That is a", end="")
    

    In Python 2.x, you can use a trailing comma:

    print "this should be",
    print "on the same line"
    

    You don’t need this to simply print a variable, though:

    print "Nope, that is not a two. That is a", x
    

    Note that the trailing comma still results in a space being printed at the end of the line, i.e. it’s equivalent to using end=" " in Python 3. To suppress the space character as well, you can either use

    from __future__ import print_function
    

    to get access to the Python 3 print function or use sys.stdout.write().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to split each line of a pipe on spaces, and then print
In gdb, I can use the print command to display a floating point or
If I have a command line like: my_script.pl -foo -WHATEVER My script knows about
I use intermediate files in my Makefile, however make prints out the rm command
I use the MS compiler from the command line (VS 2008), and whenever it
Suppose I use the printf in the find command like this: find ./folder -printf
I have to write a program that takes a command-line argument n and prints
I created a Python command-line application. One of the features is that it prints
I want my Python script to be able to read Unicode command line arguments
Trying to use the directory outputed by this line in my batch code. findstr

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.