While 10 > list[range[10, 21]]
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
However prefer the range[]
approach only if it's not running on some performance critical path. A single call is still fast enough for most requirements, but if run 10,000,000 times, we clearly notice nearly 3 times slower performance compared to a { time python3 -c "for i in range[10000000]: x = 50 in range[1, 100]"; } 2>&1 | sed -n 's/^.*cpu \[.*\] total$/\1/p'
1.848
> { time python3 -c "for i in range[10000000]: x = 1