Creating a list in Python is much like creating an array in PHP or C++. To print a list you can simply access the number of the ID just like a dimensional array. Or specify two arguments x:x. In the example below it will print 1 thru 4.

list1 = ['bob', 'dave', 'john', 'Jane','Daniel'];

list2 = [1, 2, 3, 4, 5,];

print "list1[0]: ", list1[0]

print "list2[1:4]: ", list2[1:4]

Categorized in:

Tagged in:

, , , ,