You can use two dictionaries:
totals = {'A' : 0, 'B' : 0, 'C' : 0, 'D' : 0} initials = {'A' : 0, 'B' : 0, 'C' : 0, 'D' : 0} for k in initials: if initials[k] == totals[k]: print "The population of {} has not changed".format(k)
A similar way is to identify unchanged populations:
not_changed = [ k for k in initials if initials[k] == totals[k] ] for k in not_changed: print "The population of {} has not changed".format(k)
Or you can have one structure:
info = {'A' : [0, 0], 'B' : [0, 0], 'C' : [0, 0], 'D' : [0, 0]} for k, (total, initial) in info.items(): if total == initial: print "The population of {} has not changed".format(k)
source share