def pertotal(table, option):
if option == '<STR_LIT>':<EOL><INDENT>total = sum([i for line in table for i in line])<EOL><DEDENT>t = []<EOL>for row in table:<EOL><INDENT>t_row = []<EOL>if option != '<STR_LIT>':<EOL><INDENT>total = sum(row)<EOL><DEDENT>for i in row:<EOL><INDENT>if total == <NUM_LIT:0>:<EOL><INDENT>t_row.append(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>t_row.append(i/total*<NUM_LIT:100>)<EOL><DEDENT><DEDENT>t.append(t_row)<EOL><DEDENT>return t<EOL>
calculate percent of total