list of lists
frank at chagford.com
Sun Jul 22 08:44:59 EDT 2018
"Sharan Basappa" wrote in message
news:8e261f75-03f7-4f80-a516-8318dd138657 at googlegroups.com...
> I am using a third party module that is returning list of lists.
> I am using the example below to illustrate.
> 1 results = [['1', 0.99921393753233001]]
> 2 k = results
> 3 print k
> 4 print k
> Assume the line 1 is what is returned.
> I am assigning that to another list (k on line 2) and then accessing the
> 1st and 2nd element in the list (line 3 and 4).
> How can I access elements of 1 and 0.99 without assigning it to another
As you say, results is a list of lists.
results returns the first inner list. There could potentially be more
than one, in which case results would return the second one. Use
len(results) to find out how many inner lists there are.
results returns the first element of the first inner list.
results returns the second element of the first inner list.
More information about the Python-list