Rookie Question: Passing a nested list into a function?

James Stroud jstroud at mbi.ucla.edu
Thu Apr 14 22:27:00 EDT 2005


Do you really want quotation marks around "titlelist1[x][1]" ?

e.g.

>>> textfilelist = [["titlelist1[x][1]"]]
>>> textfilelist[0][1]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IndexError: list index out of range



On Thursday 14 April 2005 06:51 pm, Brett wrote:
> I am trying to pass the value of a nested list into a function (to my "if"
> statement) as follows:
>
> textfilelist = [["titlelist1[x][1]"]]
> def idfer(listlength, comparelistlength, list):
>         while x < (listlength - 1):
>                        while y < comparelistlength:
>                             if list == titlelist2[y][1]:
> (I cutoff the end to focus on the problem)
>
> #Here i call my function hoping i am passing the value within
> textfilelist[0][0] to my function
> idfer(textfilelist[0][1], textfilelist[1][1], textfilelist[0][0])
>
>
> --------------
> I don't if there is a "legal" way to do this, but I would appreciate some
> guidance.
>
> Thanks,
>
> Brett

-- 
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/



More information about the Python-list mailing list