year = ['2017', '2018'] date = [y + str(month).zfill(2) for y in year for month in range(1, 12)] print(date) >>> output ['201701', '201702', '201703', '201704', '201705', '201706', '201707', '201708', '201709', '201710', '201711', '201801', '201802', '201803', '201804', '201805', '201806', '201807', '201808', '201809', '201810', '201811'] Zfill() Methond str.zfill(length) 문자열의 길이가 인자값인 length가 될때까지 왼쪽으로부터 0으로 삽입하여 반환 s = '100' print(s.zfill(5)) s = '+82' print(s.zfill(5)) >>> output 00100 +0082