4. String (2-6/2-7)

Source: Internet
Author: User

2-6 Sayings 2: Repeat exercise 2-5, but store the name of the celebrity in the variable Famous_person, and then create
To display the message and store it in the variable message, and then print the message.

'Albert Einstein'a person whonever made a mistake never tried anything new.' Print (Famous_person +" once Said,\""+message +"\ ".")      

To pay special attention to the \ "escape character

F5 Run

Albert Einstein once said, "a person who never made A mistake never tried anything new."

2-7 eliminate whitespace in people's names: stores a person's name and contains some whitespace characters at the beginning and end of it.
Be sure to use at least one character combination of "\ t" and "\ n".
Print the name to show the white space at the beginning and end of it. Then, using the Culling function lstrip (), respectively,
Rstrip () and strip () process the names and print the results.

  "Print (" Name is:\n "+ test_name) print ("\ t"+test_name)print(Test_name.strip ()) Print (Test_name.rstrip ()) Print (Test_name.lstrip ())

F5 Run:

Name is:

Li Xiao Long

Li Xiao Long

Li Xiao Long

Li Xiao Long

Li Xiao Long

4. String (2-6/2-7)

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.