[Tutor] Checking if value exist in a '2D array'

Olli Rajala olli.rajala at gmail.com
Fri Jun 17 08:48:02 CEST 2005

Hi again,

I have a '2D array', I mean a list inside a list ([[][],[][],...]) and
would need to check if the value exists in it. Of course I could do a
for loop, but that just seem to be a little overkill, so is there any
other way to do it? I have to check the first cell of every insider

Here's a little pseudo code if that helps.

if list[[x][0]] == 'value': # where x can be anything > 0
   print 'found'

So, is there a similar method like list.count('value') that I use for 1D lists?

Olli Rajala <><
Tampere, Finland

"In theory, Theory and Practice should be
the same. But in practice, they aren't."
- Murphy's Proverbs

More information about the Tutor mailing list