Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

# remove punctuation

# remove punctuation
import string
string.punctuation

#!"#$%&'()*+,-./:;<=>?@[]^_`{|}~

my_text = "The well-known story I told at the conferences [about hypocondria] in Boston, New York, Philadelphia,...and Richmond went as follows"
remove_punc=my_text.translate(str.maketrans('', '', string.punctuation))
print(remove_punc)


#The wellknown story I told at the conferences about hypocondria in Boston New York Philadelphiaand Richmond went as follows
Comment

remove punctuation

# define punctuation
punctuations = '''!()-[]{};:'",<>./?@#$%^&*_~'''

my_str = "Hello!!!, he said ---and went."

# To take input from the user
# my_str = input("Enter a string: ")

# remove punctuation from the string
no_punct = ""
for char in my_str:
   if char not in punctuations:
       no_punct = no_punct + char

# display the unpunctuated string
print(no_punct)
Comment

Remove Punctuation from a String

import string
 
test_str = 'Gfg, is best: for ! Geeks ;'
 
test_str = test_str.translate
    (str.maketrans('', '', string.punctuation))
print(test_str)
Comment

PREVIOUS NEXT
Code Example
Python :: repl.it secret 
Python :: python dataframe show row 
Python :: python equivalent of R sample function 
Python :: do while python 
Python :: python increase one item in list 
Python :: merge pdf 
Python :: detect gender from name 
Python :: value list in django 
Python :: python cv2 how to update image 
Python :: counter python time complexity 
Python :: Pass arguments in button tkinter 
Python :: .lstrip() 
Python :: python list remove duplicates keep order 
Python :: multiple line comments 
Python :: python typing module list 
Python :: can list hold different data types in python 
Python :: alternative to time.sleep() in python 
Python :: create sqlite table in python 
Python :: putting in text in python 
Python :: how to create dynamic list in python 
Python :: Best Python Free Tutorial 
Python :: pandas heading 
Python :: how to run class.function from name python 
Python :: how to add axis labels to a plotly barchart 
Python :: how to print random in python 
Python :: pyqt graph 
Python :: generate python 
Python :: Print statement with multiple variables 
Python :: python foreach 2d array 
Python :: django make new application folder 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =