2023-10-07から1日間の記事一覧

2つのリストを処理

1つの方法→ zip()サンプル:split で生成した2つのリスト a = 'a,b,c,d' b = '1,2,3,4' for x, y in zip(a.split(','), b.split(',')): print('%s - %s' % (x, y)) print 結果 a - 1 b - 2 c - 3 d - 4tuple のリストにする。 c = [(x, y) for x, y in zip…