I am looking to create a string of all errors returned from the API. There may be multiple errors returned in a list. Each error is a dict and the string I wish to access its the reason:
result: {
errors: [{
error: 'invalid_input',
code: 409,
reason: 'the inputted date field does not match required format'
},
{
error: 'invalid_input',
code: 409,
reason: 'the inputted message field does not match required format'
}
}
What I have tried is:
return_string = ""
if errors in result:
for error in errors:
returned_string += " {}".format(error['reason'])
Is there a more pythonic way to do it?