I'm supposed to write code in Python to remove the first and last letters in each word of a string, depending on a certain variable. So far I've tried several methods and I get some errors each time:
def trimWords(s, fromStart=1, fromEnd = 1):
return [word - word[:fromStart] - word[-fromEnd:] for word in s if word > fromStart + fromEnd]
This is what I've come up with but unfortunately it leaves me with a TypeError which I cannot find.