Stripping Whitespace Example In Python | Python Examples

#JavaInspires

 Hi Guys,

In this post, we will see rstrip(), lstrip() and strip() functions in python. We can use these functions on string objects only.


Stripping Whitespace Example In Python Program

Code :


affirmation = "  i am rich    "
print(affirmation)
#remove whitespace on right side
print(affirmation.rstrip())
#remove whitespace on left side
print(affirmation.lstrip())
#remove whitespace on both sides
print(affirmation.strip())


Output :

  i am rich    
  i am rich
i am rich    
i am rich


6 Comments

  1. Thank you for this wonderful blog.please keep updating us
    apart from this if someone is looking for the best institute in delhi for the MS OFFICE in delhi,
    I would like to talk about
    High Technologies Solutions,

    Best training institute in delhi for the ms office training
    High Technologies Solutions is the best place for learning ms office .
    Our faculties are from corporate background having more than 6 or 8 years of experience.
    you will be an expert in this feild after joining this institute
    for more details call us on 9311002620
    visit the website for more details -https://www.htsindia.com/Courses/microsoft-courses/ms-office-course

    ReplyDelete
  2. Hi, I read your whole blog. This is very nice. Good to know about the career in. Python Training & Certification , anyone interested can Python Training for making their career in this field.

    ReplyDelete
  3. Thank you for sharing an amazing & wonderful blog. This content is very useful, informative and valuable in order to enhance knowledge. Keep sharing this type of content with us & keep updating us with new blogs. Apart from this, if anyone who wants to join the MS Office Training institute in Delhi, can contact 9311002620 or visit our website-
    https://htsindia.com/Courses/microsoft-courses/ms-office-course

    ReplyDelete
  4. Hi, I read your entire blog and found it very informative. It’s great to learn about careers in Python Training & Certification. For anyone interested, pursuing Python Training can be a great step toward building a career in this field.

    python course in hyderabad

    ReplyDelete
Previous Post Next Post