[Chapter One] how do you make the output of two print () functions print on one line in Python?

Source: Internet
Author: User

The output of two consecutive print () functions is usually displayed in a branch line, that is, when you call the print () function to wrap and end the current line, what if you want two print () functions to print on one line?

We know that there are two parameters Sep and end parameters in print (). The comma in the print () function is replaced by a space by default with a newline character at the end. where Sep is substituted for the delimiter, end is the newline character in place of the ending. For example:

Coffee_cup = ' Coffee '
print ("I Love Me", Coffee_cup, "!", sep= "*") "" "The
output result is:
I love my*coffee*!
" ""

The End function is used to define a line of output

Coffee_cup = ' Coffee '
print ("I Love Me", Coffee_cup, "!", end= "End_flag") "" "The
output result is: I love my
coffee! End_flag "" "

Then, if you want to print two print () functions on one line, you can use the end argument to change the default newline character to a space or blank

Print ("Hello", end = "")
print ('
! ')
"
" "" The output result is:
hello world*! "" "



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.