I get some data payload from a users API request(from API body) usually given in a JSON format. It is stored as a Dictionary in my python code. "Data":{ "Ready Date":"2020-01-31T12:00:00", "Ready Time":"2020-01-31T12:00:00", "Delivery Date":"2020-02-15T12:00:00", "Service Level":"EC", "Close Time":"2020-01-31T17:00:00"} I want to validate the given fields. If a user does not give "Ready Date", it should say Ready Date missing and check for each object within that JSON and say if something is missing My code : I am storing all the dictionary keys in a array like : a = ["Ready Date","Ready Time","DeliveryDate","Service Level","Close Time"] My logic for value in data: if value not in a: print("value Missing" : Value) else: print("All values are entered") Result : if I gave all the values in the dictionary and the list same, My results prints : All values are entered All values are entered All values are entered if i remove any value from the the dictionary and check the condition, I get the following print result value missing : Ready Date All values are entered All values are entered I need to avoid the looping and only print it once Continue reading...