Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I totally agree with you. But I just know the basics of python: variables, print and arithmetic, nothing else. I'm studying by my self a bit more of python, but isn't still enough to make pieces of code and understand how it works. Maybe In a few months I will be able to do this and ask you again. Thank you guys and sorry.
Jhosep I've tried it several times, and have figured out that this only works when I click on a particular layer within the group layer. When I do this, the function returns the name of the group layer to layer belongs.
Jhosep don't worry, I'm grateful for your help. I close the qgis and a i restart the computer and now in the title appear the return message "Group not found". So maybe the problem is relate to the if statment, what do you think?