A really simple implementation is:
out = "".join(c for c in asking if c not in ('!','.',':'))
and keep adding any other types of punctuation.
A more efficient way would be
import string stringIn = "string.with.punctuation!" out = stringIn.translate(stringIn.maketrans("",""), string.punctuation)
Edit: There is some more discussion on efficiency and other implementations here: Best way to strip punctuation from a string in Python
Related Posts:
- Why am I seeing “TypeError: string indices must be integers”?
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- How to emulate a do-while loop?
- How to prettyprint a JSON file?
- How to install pip with Python 3?
- pip not recognised as an internal or external command
- Import Error: No module named numpy
- bash: pip: command not found
- Function for Factorial in Python
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- Writing a pandas DataFrame to CSV file
- Purpose of “%matplotlib inline”
- Importing requests module does not work
- Converting string into datetime
- How do I read CSV data into a record array in NumPy?
- How to normalize a NumPy array to a unit vector?
- Local variable referenced before assignment?
- Clickable link inside message discord.py
- DataFrame constructor not properly called! error
- OSError: [WinError 193] %1 is not a valid Win32 application
- How to download a file over HTTP?
- Can’t fix “zipimport.ZipImportError: can’t decompress data; zlib not available” when I type in “python3.6 get-pip.py”
- Arrays used as indices must be of integer (or boolean) type
- OSError [Errno 22] invalid argument when use open() in Python
- SBOX_FATAL_MEMORY_EXCEEDED error shown when Chromedriver turned 1800-1900 pages using Selenium
- Pinging servers in Python
- How can I use Python to get the system hostname?
- What is the difference between Anaconda and Pycharm?
- Add Legend to Seaborn point plot
- How to pass arguments to a Button command in Tkinter?
- How to remove specific substrings from a set of strings in Python?
- How do I install the yaml package for Python?
- Python: Array v. List
- What is key=lambda
- __init__() takes 1 positional argument but 2 were given
- Python function global variables?
- How can I convert a character to a integer in Python, and viceversa?
- What’s the difference between %s and %d in Python string formatting?
- initialize a numpy array
- error: Unable to find vcvarsall.bat
- AttributeError: Module Pip has no attribute ‘main’
- django:django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet
- Can I force pip to reinstall the current version?
- Removing pip’s cache?
- How do I check if a string is a number (float)?
- How are Pipfile and Pipfile.lock used?
- Create a .csv file with values from a Python list
- Why matplotlib does not plot?
- Where do I call the BatchNormalization function in Keras?
- unittest Vs pytest
- Add single element to array in numpy
- ‘Can’t set attribute’ with new-style properties in Python
- How to check if a string is a substring of items in a list of strings?
- How to index into a dictionary?
- Add a new item to a dictionary in Python
- reducing number of plot ticks
- Spyder Not Launching
- How do I profile memory usage in Python?
- Wait until page is loaded with Selenium WebDriver for Python
- What is the meaning of ‘for _ in range()
- How do I check if there are duplicates in a flat list?
- Difference between scikit-learn and sklearn
- How can I create a text input box with Pygame?
- How can I print variable and string on same line in Python?
- SettingWithCopyWarning even when using .loc[row_indexer,col_indexer] = value
- Append a tuple to a list – what’s the difference between two ways?
- “Divide by zero encountered in log” when not dividing by zero
- How to include external Python code to use in other files?
- How to print multiple lines of text with Python
- How to get a function name as a string?
- Substitution Cipher Python
- Good ways to “expand” a numpy ndarray?
- Python data structure sort list alphabetically
- TypeError: ‘numpy.float64’ object does not support item assignment
- TypeError: unsupported format string passed to list.__format__
- Extract a part of the filepath (a directory) in Python
- Python 3.5.1 urllib has no attribute request
- Rotating a two-dimensional array in Python
- TypeError: sequence item 0: expected string, int found
- Why am I getting this unexpected keyword argument TypeError?
- Create numpy matrix filled with NaNs
- python pandas remove duplicate columns
- What is the difference between __str__ and __repr__?
- How often does python flush to a file?
- How to open every file in a folder
- cmake error ‘the source does not appear to contain CMakeLists.txt’
- ubuntu /usr/bin/env: python: No such file or directory
- How to completely uninstall python 2.7.13 on Ubuntu 16.04
- Calculate weighted average using a pandas/dataframe
- Telling Python to save a .txt file to a certain directory on Windows and Mac
- Spell Checker for Python
- TypeError: coercing to Unicode: need string or buffer, int found
- Python MySQLdb not importing
- Write a program that asks the user to enter five test scores. Correspond it to a letter grade
- Simplify Chained Comparison
- How to get POSTed JSON in Flask?
- How to fix SSL issue SSL_CTX_use_certificate : ca md too weak on Python Zeep
- Paramiko’s SSHClient with SFTP
- Package libffi was not found in the pkg-config search path REDHAT6.5
- Line is too long. Django PEP8