if report == True:
print ("\tActive parts:\t%s")%(len(pact)) # TOTAL P Part and Active
print ("\tDiscontinued parts:\t%s")%(len(pdisc)) # TOTAL P Part and Discontinued
print ("\tSlow-moving parts:\t%s")%(len(pslow)) # TOTAL P Part and Slow-moving
print ("\tObsolete parts:\t%s")%(len(pobs)) # P TOTAL Part and Obsolete
How could I best simplify the above? I have roughly 80 other print statements such as that which are steadily make the code very difficult to work with?
Re-factor your code so that your individual variables are stored in a dictionary, e.g.,
Or even as attributes of a class,
Then you’d create a separate list of strings to describe each attribute, such as:
Then you can print them like this: