Check for existance of attribute in object

Published: 28/08/2019
Check for existance of attribute in object
Source: STACKOVERFLOW.COM

I have some code, which get an object and I need to check if the attribute description in testobj and then add this description to the new object else don't add description to the newobj: Example of object: testobj= [{'name': 'testname', 'description': 'testdescription'}, {'name': 'testname'}] My code: for _ in testobj: newobj = { 'name': _['name'], 'description': _['descriptio

Read more
Related news
Comment
FACEBOOK