```
filenames = ["program.c", "stdio.hpp", "sample.hpp", "a.out", "math.hpp", "hpp.out"]

```

I want to replace the .hpp with .h.

```
y=[]
for x in filenames:
    if '.hpp' in x:
        x=x.replace('hpp','h')
        y.append(x)
    else:
        y.append(x)
print(y)

```

Is there an easier way to do this?