473,414 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

index of list of lists

yes, there's a thread with the same title, but I believe mine is more
appropriate title.
so, as much as I search on the web, read manuals, tutorials, mail-lists
(including this one) I cannot figure it out how to search a string in a
list of lists.
like this one:

someList = [['somestring', 1, 2], ['oneother', 2, 4]]

I want to search "somestring" in someList which is in practice a list
of aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge
me).
is the list.index the wrong approach?
should I use numpy, numarray, something else?
can anyone, be kind and help me with this?

Jun 27 '08 #1
1 1157
On Thu, 17 Apr 2008 05:15:52 +0300, Daniel NL wrote:
yes, there's a thread with the same title, but I believe mine is more
appropriate title.
so, as much as I search on the web, read manuals, tutorials, mail-lists
(including this one) I cannot figure it out how to search a string in a
list of lists.
like this one:

someList = [['somestring', 1, 2], ['oneother', 2, 4]]

I want to search "somestring" in someList which is in practice a list of
aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge me).
is the list.index the wrong approach? should I use numpy, numarray,
something else? can anyone, be kind and help me with this?
You probably need something like this:
[x for x, y, z in someList if x == 'somestring']

or this:
for x, y, z in someList:
if x == 'somestring':
return x

--
Ivan
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
4
by: techiepundit | last post by:
I'm a Python newbie who just started learning the language a few weeks ago. So these are beginner questions. I have a list of sockets that I use for select.select calls like this: ...
2
by: Martin v. Löwis | last post by:
I've been working on PEP 353 for some time now. Please comment, in particular if you are using 64-bit systems. Regards, Martin PEP: 353 Title: Using ssize_t as the index type Version:...
11
by: JJLaRocque | last post by:
Hi all, Is there a simple python function to return the list index of the minimum entry in a list of lists? ie, for , , ] to return 2,4. Or, same question but just for a list of numbers, not a...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
122
by: C.L. | last post by:
I was looking for a function or method that would return the index to the first matching element in a list. Coming from a C++ STL background, I thought it might be called "find". My first stop was...
96
by: zzbbaadd | last post by:
What's with the index() function of lists throwing an exception on not found? Let's hope this is rectified in Python 3. If nothing else, add a function that doesn't throw an exception. There are a...
6
by: xkenneth | last post by:
Looking to do something similair. I'm working with alot of timestamps and if they're within a couple seconds I need them to be indexed and removed from a list. Is there any possible way to index...
0
by: Kam-Hung Soh | last post by:
On Thu, 17 Apr 2008 12:25:51 +1000, Daniel Fetchinson <fetchinson@googlemail.comwrote: See also Section 4.5. Filtering Lists. List comprehension: == 'somestring']
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.