I work with Core Telegram API. I get a list of participants in the chat, information on the participant is displayed in this form
{ "_": "pyrogram:ChatMember", "user": { "_": "pyrogram:User", "id": 456488888, "is_self": false, "is_contact": false, "is_mutual_contact": false, "is_deleted": false, "is_bot": false, "first_name": "user" }, "status": "member" } or such an example
{ "_": "pyrogram:ChatMember", "user": { "_": "pyrogram:User", "id": 483362460, "is_self": false, "is_contact": false, "is_mutual_contact": false, "is_deleted": false, "is_bot": false, "first_name": "\u0412\u0438\u043a\u0442\u043e\u0440\u0438\u044f", "last_name": "\u041a\u043e\u043c\u0430\u0440\u043e\u0432\u0430", "photo": { "_": "pyrogram:ChatPhoto", "small_file_id": "AQADAgADqacxG6ytzxwACCsSMw4ABDYsn7Nwvs8xgJsAAgI", "big_file_id": "AQADAgADqacxG6ytzxwACCsSMw4ABHg-J0efOQjJgpsAAgI" } }, "status": "member" } I want to get the data of a single element, let's say I need all the surnames of users, but this element may not be, how can I skip or replace the missing element, for example with a dash.
I deduce so
data.user.last_name and this last_name may not be there, the script gives an error, what check to make? Maybe I have not quite clearly described my question, not so long ago I began to learn Python.