mardi 24 août 2021

If loop which exits as fail based on the output value [closed]

I am trying to write a if loop for the following print stament:

data1 = r.json()
print(data1)
#This is the output of print statement <Response [200]>
# {'value': 0, 'valueName': 'errorCountTestCases-tier1'}
# Now i want to write a if loop which checks the value here from the list, and fails if the 
 value is not equal to 0 or greater than 0 (anything if fine)
# I have the following code
if data1 != 0:  #### i understand i cant do like this
# ERRORS occurred, exit.
print('Errors detected sending email')
sys.exit(1)

Can someone help me, how to do it. Or if there is any better way for this.

Aucun commentaire:

Enregistrer un commentaire