If you want to remove all files that end with “.txt”, you can use the combination of glob and pathlib as shown above.