Python get category of element

Is it possible to get the category of an element with python?
I have a script where I can get all the elements from selected views or view.

Now I want to sort the elements based on their category. I am thinking on doing this with another python node.

The idea

The MEPover package has a node to do exactly what you show in your screenshot. You could potentially copy reference their Python code if you’re trying to avoid custom packages.

Likely you should be using a different method on the initial filtered element collector.

Several examples can be found in this repository: GitHub - Amoursol/dynamoPython: Python Modules for Dynamo

What is the error message you are getting?

Thanks I got it to work!

Thanks for the link, I will look into it to understand Python in Dynamo better.