Friday 15 August 2014

Printing out an element of a list in Python -



Printing out an element of a list in Python -

i have list of lists so:

a = [1,2,3] b = [2,3,4] c = [3,4,5] lists = [a,b,c]

i want print out name of first element in "lists" so:

print lists[0]

but of course of study python not work , this:

print lists[0] [1,2,3]

how can print out name of lists[0] without printing contents of lists[0]?

sounds want utilize ordereddict:

from collections import ordereddict dlists = ordereddict([('a', [1,2,3]), ('b', [2,3,4]), ('c', [3,4,5])]) print dlists.keys()[0]

python list

No comments:

Post a Comment