Print Two Things On The Same Line


https://youtu.be/jAXANpLRcmE

Short and sweet today:

You can tell print() not to print the newline character at the end of the line with:

print("Hello",end='')

print("World")

To create the following output:

HelloWorld

You can change the print zone separator character with:

print("Age",25,"Name","Bob","Cash",12.54,sep="|")

To create the following output:

Age|25|Name|Bob|Cash|12.54

Or to output a comma separated list: you can change the print zone separator character with:

print("Age",25,"Name","Bob","Cash",12.54,sep=",")

To create the following output:

Age,25,Name,Bob,Cash,12.54

Use "\t" for the tab character as separator to output for a tab separated list.

And in the spirit of making things useful, you can format for HTML newlines with:

print("Hello",end="<br />\n")

print("World",end="<br />\n")

Which outputs as:

Hello<br />

World<br />

But in a web browser it looks like:

Hello

World

Next Post: Comments

Recent Posts
Tags

© 2019 BrainStemSchool.com