[Tutor] A dictionary question
Phil
phillor9 at gmail.com
Sat Nov 20 19:10:37 EST 2021
On 20/11/21 20:03, Alan Gauld via Tutor wrote:
>
> The code is easier to read and more reliable, easier to maintain.
> (It's less liable to index errors) It's also more Pythonic so
> other Python programmers (and probably even you in 6 months
> time) will understand it faster.
OK Alan, understood.
Just one thing though, a snippet from the code that Mats generously gave me.
for r in row:
if i in r:
icount += 1
I need the set position within the row list so I did this:
for r in range(num_rows):
if i in row[i]:
icount += 1
irow = row[i]
Is this a task for enumerate? A brief test showed this not to be the
case but I will experiment some more.
--
Regards,
Phil
More information about the Tutor
mailing list