how to format printing in PYTHON without object length -
so have data i'm trying print file within columns.
this current formatting:
print_to_file = open('best_and_worst.txt', "w") print("category {:>25s} best {:>25s} worst".format('',''), file=print_to_file) print("heart disease:{0:21s}".format(best_hd_state), file = print_to_file)
what want print spaces distance category (in case "heart disease:") until it's aligned "best", print 1 space , value , after print spaces until aligned "worst" print state, space, , value.
the problem encounter don't know how deal varying length of objects , further don't know how have variable formatting. (i.e. adjusting number of spaces according length of object , distance between , next column want align with.) whole point of program organize state data csv file , print information new file. can't use single value while formatting because if state data changes things fall out of line. please halp.
Comments
Post a Comment