[Tutor] List of ints
Albert-Jan Roskam
fomcl at yahoo.com
Wed Mar 4 20:16:34 CET 2015
----- Original Message -----
> From: Mark Lawrence <breamoreboy at yahoo.co.uk>
> To: tutor at 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, 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 way to debug simple things like this is quite simple:
>>
>> print count[0]
>>
>> which will show you that count[0] is a list [0], not an int 0, and you
>> are trying to add [0]+1 which doesn't work.
>>
>> Never under-estimate the usefulness of a few print calls when debugging.
>>
>>
>
> About time we threw in the use of the interactive interpreter for trying
> code snippets as well, just for good measure :)
Perhaps both at the same time using the PDB debugger from within IPython?
%run -d -b <line number> myscript.py
d = debug, b = breakpoint
inside pdb: c = continue, q = quit, p = print, r = return value of current function, s = step, and more: https://docs.python.org/2/library/pdb.html
More information about the Tutor
mailing list