Comparison and ranges
Check the indices supplied by a range
A range describes positions and a comparison checks a condition at a position.
for index in 0..3:
print(index == 2)
false
false
true
Only the third visited index equals 2. The end of the range is excluded.
Comparisons between numeric kinds preserve integer precision. NaN is unequal to every value, and all ordered comparisons involving NaN are false. Ordering between text values follows Unicode scalar order. Other types support equality by value or reference identity as appropriate.
Ranges require signed integer endpoints and a half-open upper bound. A range with an end at or below its start iterates zero times. Exact endpoints still matter for equality. Slice bounds must be ordered, nonnegative and within the source.