title: Is there any replace function in list comprehension?
body: <p>Given a list of filenames, we want to rename all the files with extension hpp to the extension h. To do this, we would like to generate a new list called newfilenames, consisting of the new filenames. Fill in the blanks in the code using any of the methods you’ve learned thus far, like a for loop or a list comprehension.</p>
  <pre><code>filenames = [&quot;program.c&quot;, &quot;stdio.hpp&quot;, &quot;sample.hpp&quot;, &quot;a.out&quot;, &quot;math.hpp&quot;, &quot;hpp.out&quot;]
  # Generate newfilenames as a list containing the new filenames
  # using as many lines of code as your chosen method requires.
  ___  
  
  print(newfilenames) 
  # Should be [&quot;program.c&quot;, &quot;stdio.h&quot;, &quot;sample.h&quot;, &quot;a.out&quot;, &quot;math.h&quot;, &quot;hpp.out&quot;]
  </code></pre>
  <p>I only know how to find the names with .hpp extension but I don't know how to replace it with .h</p>
  <pre><code>newfilenames=[x for x in filenames if x.endswith('.hpp')] 
  </code></pre>