Python shortcut ?

Santanu Chatterjee santanu at softhome.net
Sun Oct 12 15:35:58 EDT 2003


Hello everybody,

I am very new to Python. So pardon me if this question is
too dumb.

Suppose I have the following list:
    myList = [('a','hello), ('b','bye')]

How do I get only the first element of each tuple in the
above list to be printed without using:
    for i in range(len(myList)):
        print myList[i][0]
or:
    for i in myList:
        print i[0]
 
I tried:
    print myList[:][0]
but it seems to have an altogether different meaning.

Regards,
Santanu





More information about the Python-list mailing list