There are two lists, we find the data.
Given:
v = [465,641,638,637,644,645,648,689,709,1022,1032,1065,1067] g = [(705L,), (637L,), (638L,),] I receive:
res = [x for x in g if x[0] in v] print res [(637L,), (638L,)] Bypassing the sequence, the options are interested in how to simplify the code block
x = [] for j1 in res: #тут передаем данные в MySQL res2 = dbHandle.execute(sql.format(j1[0],'mul_add)).fetchall() if res2: x.append(res2)