strip
does not remove whitespace everywhere, only at the beginning and end. Try this:
def solve_eq(string1):
return string1.replace(' ', '')
This can also be achieved using regex:
import re
a_string = re.sub(' +', '', a_string)
More Related Contents:
- Not sure how to tackle this [closed]
- Get raw key value
- Python import csv to list
- How to make separator in pandas read_csv more flexible wrt whitespace, for irregular separators?
- UnboundLocalError with nested function scopes
- Repeating elements of a list n times
- Search for String in all Pandas DataFrame columns and filter
- How to get the nth element of a python list or a default if not available
- Getting “Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?” when installing lxml through pip
- Calling a function upon button press
- Predict classes or class probabilities?
- Handling urllib2’s timeout? – Python
- Matplotlib Plot Lines with Colors Through Colormap
- How to make a custom object iterable?
- How to use “raise” keyword in Python [duplicate]
- Python Sound (“Bell”)
- Identifier normalization: Why is the micro sign converted into the Greek letter mu?
- When to use os.name, sys.platform, or platform.system?
- import pandas_datareader gives ImportError: cannot import name ‘is_list_like’
- What are the differences between Bot and Client?
- Does Python evaluate if’s conditions lazily? [duplicate]
- Read csv from Google Cloud storage to pandas dataframe
- python list comprehension double for
- Get name of current class?
- Is it possible to read FTP files without writing them using Python?
- overcome Graphdef cannot be larger than 2GB in tensorflow
- How do you divide each element in a list by an int?
- Deleting User Messages in Discord.py
- Python Lambdas and Variable Bindings [duplicate]
- How can I profile a multithread program in Python?