Friday, June 22, 2012

Dictionaries in jython


Dictionaries

Dictionaries are arrays of objects indexed on a key (string value) and not by an index.
A dictionary is accessed with a tuple key:value separated by commas and in brackets.
·         {} is an empty dictionary
·         {'P1':'Watch', 'P2': 'Birds', 'P3':'Horses'} is a dictionary with 3 elements with the following keys: P1, P2 and P3
·         adict = {'FR_US':{'Bonjour':'Hello', 'Au revoir':'Goodbye'}, 'US_FR':{'Hello': 'Bonjour','Goodbye':'Au Revoir'}} is a dictionary that contains other dictionaries. To translate 'Hello' in French:: adict['US_FR']['Hello']

No comments:

Post a Comment