Gia Constantina Gia Constantina - 2 months ago 4x
Python Question

Printing strings and variables on the same line

I have a header array with three things in it. My program goes through all the combinations of headers and sees if they are concurrent or not concurrent.

When I run the program I want it to print which two headers are concurrent and which are not concurrent. So basically when it prints, instead of it printing

sequences are concurrent
sequences are not concurrent
, I want it to say
header a is concurrent to header b
header b is not concurrent to header c

This is my program as it stands:

for p in combinations(sequence,2):
if p[0][start:stop]==p[1][start:stop]:
print header[p[0],p[1]], "are concurrent"
print header[p[0],p[1]], "are not concurrent"
print list(c)

I know the problem is line four and six. Please help. With this code I get
TypeError: list indices must be integers, not tuple.

Someone asked for an example of my headers and sequences...
My headers are as follows:
('>DQB1', '>OMIXON', '>GENDX')

My sequences are as follows:


You want to combine the two lists into one:

for (h1, s1), (h2, s2) in combinations(zip(header, sequence), 2):
    if s1[start:stop] == s2[start:stop]:
        print h1, h2, "are concurrent"
        print h1, h2, "are not concurrent"