I am trying to solve the python exercise for 'remove suffix ness from the string' and have written the following code, but I am unable to pass the test
def remove_suffix_ness(word):
no_suffix = [word[:-4] for word in word]
for i in range(len(no_suffix)):
if no_suffix[i][-1] == 'i':
no_suffix[i] = no_suffix[i][:-1] + 'y'
else:
pass
return ', '.join(no_suffix)
The code is supposed to take the following as Input:
Input = ['heaviness', 'sadness', 'softness', 'crabbiness', 'lightness', 'artiness', 'edginess']
and Output should be a string without ness and if the string is ending with 'i' I have to replace 'i' with 'y'. It should look something like this:
Output = heavy, sad, soft, crabby, light, arty, edgy
I am getting the following message:
TEST FAILURE
IndexError: string index out of range