exercism code:
def remove_suffix_ness(word):
“”"Remove the suffix from the word while keeping spelling in mind.
:param word: str - of word to remove suffix from.
:return: str - of word with suffix removed & spelling adjusted.
For example: "heaviness" becomes "heavy", but "sadness" becomes "sad".
"""
words_sufix = []
for sufix in word:
if sufix.endswith('iness'):
sufix = sufix[:-5]
sufix = sufix + 'y'
words_sufix.append(sufix)
continue
sufix = sufix[:-4]
words_sufix.append(sufix)
return words_sufix
It doesn’t pass the tests, but python tutor tests it and it does pass the test.
python tutor code:
def remove_suffix_ness(word):
“”"Remove the suffix from the word while keeping spelling in mind.
:param word: str - of word to remove suffix from.
:return: str - of word with suffix removed & spelling adjusted.
For example: "heaviness" becomes "heavy", but "sadness" becomes "sad".
"""
words_sufix = []
for sufix in word:
if sufix.endswith('iness'):
sufix = sufix[:-5]
sufix = sufix + 'y'
words_sufix.append(sufix)
continue
sufix = sufix[:-4]
words_sufix.append(sufix)
return words_sufix
remove_suffix_ness([‘heaviness’, ‘sadness’, ‘softness’, ‘crabbiness’, ‘lightness’, ‘artiness’, ‘edginess’])