I want to replace any word that ends with "hpp" in the list to instead end with "h". You can see what it is meant to output in the bottom comment. Insted, the string just doesn't get replaced. I am very confused as to why this is and any help is great!
filenames = ["program.c", "stdio.hpp", "sample.hpp", "a.out", "math.hpp", "hpp.out"]
# Generate newfilenames as a list containing the new filenames
newfilenames = []
for i in filenames:
if i[len(i) - 3:len(i)] == "hpp":
i.replace("hpp", "h")
newfilenames.append(i)
else:
newfilenames.append(i)
print(newfilenames)
# Should be ["program.c", "stdio.h", "sample.h", "a.out", "math.h", "hpp.out"]