[Tutor] List of ints
Phil
phil_lor at bigpond.com
Tue Mar 3 07:50:41 CET 2015
Thank you for reading this.
Python 3 under Linux.
I'd like to set up a two dimensional list of counters as follows;
count = [
[0],
[0],
[0]
]
And then increment the first counter as follows;
count [0] += 1
This fails with the following error;
TypeError: 'int' object is not iterable
The array module looks like the answer because it seems to function in
the same way as an array under C. However, it seems to me that I should
be able to do the same thing with a list.
Is there a way to add a value to a list of ints?
--
Regards,
Phil
More information about the Tutor
mailing list