Re: [Tutor] List of ints

2015-03-04 Thread Albert-Jan Roskam
- Original Message - > From: Mark Lawrence > To: tutor@python.org > Cc: > Sent: Wednesday, March 4, 2015 10:20 AM > Subject: Re: [Tutor] List of ints > > On 04/03/2015 00:25, Steven D'Aprano wrote: >> On Tue, Mar 03, 2015 at 04:50:41PM +1000, Phi

Re: [Tutor] List of ints

2015-03-04 Thread Mark Lawrence
On 04/03/2015 00:25, Steven D'Aprano wrote: On Tue, Mar 03, 2015 at 04:50:41PM +1000, Phil wrote: count [0] += 1 This fails with the following error; TypeError: 'int' object is not iterable I know that others have already solved the problem, but here is something which might help you solve

Re: [Tutor] List of ints

2015-03-04 Thread Alan Gauld
On 03/03/15 23:44, Mark Lawrence wrote: Having never heard of QPython I've just looked it up, so for those who don't know from http://qpython.com/ it's "a script engine which runs Python programs on android devices". I doubt if there is much experience on this list with it although you might ge

Re: [Tutor] List of ints

2015-03-03 Thread Steven D'Aprano
On Tue, Mar 03, 2015 at 04:50:41PM +1000, Phil wrote: > count [0] += 1 > > This fails with the following error; > > TypeError: 'int' object is not iterable I know that others have already solved the problem, but here is something which might help you solve similar problems in the future. The

Re: [Tutor] List of ints

2015-03-03 Thread Steven D'Aprano
On Wed, Mar 04, 2015 at 09:09:03AM +1000, Phil wrote: > I'd been away from home for five weeks and during a quiet period I > installed QPython on my tablet with the aim of porting a programme that > I'd written in C++ 15 years ago to Python. Cutting and pasting and even > moving around the IDE

Re: [Tutor] List of ints

2015-03-03 Thread Mark Lawrence
On 03/03/2015 23:09, Phil wrote: On 03/03/15 17:46, Mark Lawrence wrote: You are trying to increment the first element of count which is itself a list containing one element. You actually need:- count[0][0] +=1 Thank you Lawrence, Alan, and Danny, The solution is embarrassingly obvious. I

Re: [Tutor] List of ints

2015-03-03 Thread Phil
On 03/03/15 17:46, Mark Lawrence wrote: You are trying to increment the first element of count which is itself a list containing one element. You actually need:- count[0][0] +=1 Thank you Lawrence, Alan, and Danny, The solution is embarrassingly obvious. It's been a long time since I've a

Re: [Tutor] List of ints

2015-03-03 Thread Danny Yoo
On Mon, Mar 2, 2015 at 10:50 PM, Phil wrote: > 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] > ] > Can you explain why the list is two-dimensi

Re: [Tutor] List of ints

2015-03-03 Thread Alan Gauld
On 03/03/15 06:50, Phil wrote: 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 Are you trying to increment the zero to make it 1? Or are you trying to add a new value, 1, to the first

Re: [Tutor] List of ints

2015-03-02 Thread Mark Lawrence
On 03/03/2015 06:50, Phil wrote: 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

[Tutor] List of ints

2015-03-02 Thread Phil
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; TypeE