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.
,
) at the end of the line. Note that it will still make theprint
statement print a whitespace instead of a newline. – Melchizedekthe sys.stdout.write
command (and it is a more advanced thread). Since i have started programming today, i did not understand them. (I found several more very similar threads, like 5, but i didnt understand or the questions werent the exact same) – Minimus