to check existence of list in list of lists

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Roshini Shyam
    New Member
    • Nov 2011
    • 1

    to check existence of list in list of lists

    Hi Everyone,
    I am new to python
    I would like to know if i can check the existence of a list in a list of lists-
    if List in List_of_Lists:
    does not seem to work.
    and also once the existence is verified i would like to know the index of that particular list
    will List_of_Lists.i ndex(List) work??
    Thanks in advance
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    if List in List_of_Lists:
    compares lists, so there has to be a list in "Lists_of_Lists " that is exactly the same as the list, "List". You can use instead, i.e. is the same thing:
    Code:
    for this_list in List_of_Lists:
        if this_list == List:
            ## add code here to do what you want
    does not seem to work.
    offers nothing that anyone can use to help.

    Comment

    Working...