Newbie Question: Giving names to Elements of List/Tuple/Dict

Hamish Lawson hamish_lawson at yahoo.co.uk
Fri Nov 29 11:27:19 EST 2002


Alfredo P. Ricafort wrote:

> It seems that when you define a data structure in the form of a List, Tuple, 
> or Dict., there is no way to give names to each element.

Dictionaries actually *must* be keyed by an explicitly provided key, often a string:

customer = {'name': 'Bob Smith', 'address': '12 Main St', 'TelNo': '768 8686'}
print customer['name']


Hamish Lawson



More information about the Python-list mailing list