ad = {
'insights': {
'outbound_clicks': [
{
'value': 1.0
}
]
}
}
print(next(iter(ad.get('insights', {}).get('outbound_clicks', [])), {}).get('value', 0.0))
# Result : 1.0
ad = {
'insights': {
'outbound_clicks': []
}
}
print(next(iter(ad.get('insights', {}).get('outbound_clicks', [])), {}).get('value', 0.0))
# Result : 0.0
Last active
February 23, 2018 06:07
-
-
Save gotraveltoworld/f27bfd091669457ae307a8b6d759e089 to your computer and use it in GitHub Desktop.
Python list out of index handler by iter(Facebook ads insights report)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment