I have strings of the form
sent="Software Development = 1831".
I want to extract only words from the string i.e. "Software Development". How I can extract this in Python.
I have strings of the form
sent="Software Development = 1831".
I want to extract only words from the string i.e. "Software Development". How I can extract this in Python.
You can try split
:
>>> sent="Software Development = 1831"
>>> sent.split("=")[0]
'Software Development '
>>> str="Software Development = 1831"
>>> str.split()
['Software', 'Development', '=', '1831']
or
>>> str.split("=")
['Software Development ', ' 1831']
Initially you have spaces between '='
, hence your code should look like this
sent="Software Development = 1831"
answer=sent.split(" = ")[0] # space before and after =