Each Entry Of A List Nummered Bij Order
I am trying to nummer all my entry's in a list by order my script is : for item in klantgegevens: teller = (number, item) number = number + 1 print teller
Solution 1:
You are looking for the builtin enumerate
function. It seems that you have a list with one element that is a list of lists so you have to call enumerate
on this one element (the list of lists):
for teller in enumerate(klantgegevens[0]):
print teller
Solution 2:
use enumerate()
here:
In [229]: klantgegevens=[['Cautus B.V. Zei 9-11', 'Cautus B.V.', '1', '2', '', '', '', '', '', ' Zei 9-11', '1009023', '10', 'Geachte Daa', 'Mevrouw Daa', 'chaa.c2000@planet.nl'],
['Cautus B.V. 32', 'Cautus B.V.', '1', '2', '', '', '', '', '', 'Trias 92', '1109008', '10', 'Geachte mevrouw Daa', 'Mevrouw Daa', 'chaa.c2100@planet.nl']]
In [231]: for i,x in enumerate(klantgegevens):
.....: print (i,x)
.....:
.....:
(0, ['Cautus B.V. Zei 9-11', 'Cautus B.V.', '1', '2', '', '', '', '', '', ' Zei 9-11', '1009023', '10', 'Geachte Daa', 'Mevrouw Daa', 'chaa.c2000@planet.nl'])
(1, ['Cautus B.V. 32', 'Cautus B.V.', '1', '2', '', '', '', '', '', 'Trias 92', '1109008', '10', 'Geachte mevrouw Daa', 'Mevrouw Daa', 'chaa.c2100@planet.nl'])
Post a Comment for "Each Entry Of A List Nummered Bij Order"