Post

PythonPython

A
Anusha V

Posted on 28th March 2024|40 views

0
votes

Python Remove Special Characters From String

How can I remove all the special characters, punctuations and spaces from a string in python?

Answers
P
divija reddy

Posted on 28th March 2024

Try this example

>>> string = "Hey $#! People howareyou 007"

>>> ''.join(e for e in string if e.isalnum())

'Heypeoplehowareyou007'

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos