@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic
(No. 2241 / 12833)
zip() stops when the shortest sequence is done
alist = [ 'A', 'B', 'C', 'D' ]
blist = [ 1, 2, 3 ]
for alph, num in zip(alist, blist):
print(alph, num)
結果
Success time: 0 memory: 23352 signal:0
('A', 1)
('B', 2)
('C', 3)
教えていただいた事項
(追記 2017/03/24)
@Tsutomu-KKE@github さんのコメントにてitertools のzip_longest()
を教えていただきました。
情報感謝です。