if i have a procedure such as:
def P(x):
# x is an integer
print str(x)
and i want to have an output such as:
>>> You chose the number: X
where X is the result printed inside procedure P.
How can I do that without changing the procedure?
If I do like this:
print 'You chose the number: '
P(x)
I’ll get
You chose the number:
X
How can I get them in the same line?
Add a
trailingcomma after the first print statement, to print the next statement in the same line: –