Friday, June 22, 2012

Lists in jython


Lists

Lists are arrays of modifiable references to objects, accessed with an index.
A list is a series of values separated by commas and enclosed in brackets.
·         [] is an empty list
·         [0, 1, 2, 3, 4, 5] is a list of 6 elements indexed from 0 to 5
·         mylist = ['john', 1, ['albert', 'collin']] is a list of 3 elements where the  2 index (third element) is also a list
mylist[2] returns ['albert', 'collin']
mylist[2][1] returns 'collin'

No comments:

Post a Comment