Reputation: 23
how do i print the highest index number?
Upvotes: 0
Views: 146
Reputation: 4813
The highest index is just one less than the length of the list. So:
puts [expr {[llength $list] - 1}]
To print the element at the largest index, you can refer to it as 'end':
puts [lindex $list end]
If I misunderstood the question and you want the index of the largest number in the list, that can be done as follows:
puts [lindex [lsort -indices -integer -decreasing $list] 0]
Upvotes: 2