Use `endswith` and list comprehension.

The script that interfaces with the module was not using list
comprehension and was not compliant with the PEP8 standard for checking
extensions.