range
Description
The range() function generates a new list from the elements in a list, starting at the element number that is specified by index1 and ending with the element number that is specified by index2.
The first element in a list always has an index value of 0. An index number that is larger then the last index in the list is treated as the last element. In the case where index1 is larger than the last index in the list, an empty list is returned (that is, with a list length equal to 0).
Syntax
result = range (list1, index1, index2);
Arguments
list1 | Required. The list from which a new list is extracted. |
index1 | Required. The element number, in list1, at which the extraction should begin. |
index2 |
Required. The element number in list1 at which the extraction should end, inclusive. |
Return Values
result Contains the new list that was extracted from list1.
list1 = {"JWhite", "SBrown", "RRoads"}; result = range (list1, 1, 2);
In this example, result contains the following list:
{"SBrown", "RRoads"}