Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Python
  3. Question
Python

How to remove underscores and spaces from a string effectively using Phython?

Asked by Chloe Burgess Jun 20, 2024 4.3K views 2 answers
Share

About this question

I am trying to strip the characters '_ ' (underscore and space) away from my string. The first code fails to strip anything. The code for word_1 works just as I intend. Could anyone enlighten me how to modify the first code to get output 'ale'?

word = 'a_ _ le' 
word.strip('_ ')
word_1 = '_ _ le'
word_1.strip('_ ')

Your answer

2 Answers

More Python discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Python Blogs

Guides, tips and career advice on Python from JanBask experts.