Question: I'm working with Python 3, and I need to validate document files (such as *.pdf*, *.xlsx*, and *.docx*) that I get by request like a binary. I'm currently using a little function that gets the hexa for the extension, but it only works with *.pdf*.

It looks like this:

```
def validate_binary_extension(self, file):
        extension = file[0:3].hex()
        extencions = ['255044', 'D0CF11', "D0CF11"]
        if  extension in extencions:
            return True
        else: 
            return False

```

I read the hexa for *.doc* and *.exe*, but I don't know how to get the extensions for those types of documents.

Answer: 
An obvious problem is that `.hex()` returns *lowercase* hex, and you provided uppercase hex constants. The first one would work because the hex is purely digits, but `'D0CF11'` should be `'d0cf11'` if you want it to match the output of `bytes.hex()`.
If you wanted to get the extension name, you could do:

```
def get_extension_name(filename):
    for index, char in enumerate(filename):
        if char == ".":
            return filename[index + 1:]

```