As a test. A method for when you want to display multiple strings of the same length side by side. Output similar to the result of BLAST etc.
from math import ceil
hoge = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
fuga = "abcdefghijklmnopqrstuvwxyz"
def multi_line(str_list, col_length):
# str_The length of the character string in list is the same
for k in range(int(ceil((float(len(str_list[0])))/col_length))):
e = (k + 1)*col_length if (k+1)*col_length < len(str_list[0]) else len(str_list[0])
for s in str_list:
print s[k*col_length:e]
print "\n"
multi_line([hoge, fuga], 13)
# This will produce:
# ABCDEFGHIJKLM
# abcdefghijklm
#
# NOPQRSTUVWXYZ
# nopqrstuvwxyz
#
Recommended Posts