This is driving me crazy. I have a string like this:
Sheridan School III
In a list like this:
Sheridan School III
Lake Bluff Elementary II
Barrington IV
I'd like to make the trailing portion into a variable homeseries
And make the portion that precedes that into variable homeclub
When I split the string I can get the series, no problem, as in below.
But I cannot use that series inside the .replace string, where I'd like to just use it to get rid of the last part of the original string. How do I use a variable inside .replace? Python throws an error and I'm sure there is a simple way to reference this as a variable.
homeclubfull = "Sheridan School III"
homeclublist = homeclubfull.split(" ")
homeseries = homeclublist[-1:] # this should return "III"
homeclub=homeclubfull.replace(homeseries,'')
print homeclub, home series
error thrown:
import.py:51: TypeError: expected a character buffer object