topics1 = ['MAR', 'STA'] topics2 = ['KST', 'ABS', 'KTR'] accounts = [] for t in topics1: accounts += [t + '_' + str(i).zfill(2) + ';n.v.\n' for i in range(10)] for t in topics2: accounts += [t + '_' + str(i).zfill(2) + ';n.v.\n' for i in range(100)] with open('Kontenrahmen_Merkmale.csv', 'w') as f: f.writelines(accounts)