Post

PythonPython

S
Sowjanya Kodiganti

Posted on 4th March 2024|16 views

0
votes

Remove Punctuation From String Python

How to remove punctuation marks from a string in Python 3.x?

Answers
P
Anusha V

Posted on 4th March 2024

You can simply remove all the punctuation by using this

import re, string 

eclean_string = re.sub(rf"[{string.punctuation}]", "", dirty_string)

 

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