3 ms·
Okay, I’m getting confused because the code does test for 10p.
by moomin 9y ago
Okay, I’m getting confused because the code does test for 10p.
- ColinWright 9y agoI don't think it does. Are you aware that "range(1,10)" in Python is the list [1, 2, 3, 4, 5, 6, 7, 8, 9] ?? Ranges in Python don't include their endpoint. A few people have expressed confusion as to this choice in the design, but it means that the expression: range(a,b) + range(b,c) + range(c,d) includes everything from a to d-1 one and only once. Knuth said that intervals should include the initial point and not the endpoint for this reason.
- moomin 9y agoAaaah. Makes sense.
- mclehman 9y agoThis issue is one of the things Perl 6 addresses well in my opinion. Regular ranges include their endpoints, and you can think of ^ as "not including" or "up to (exclusive)" 1..5 is 1, 2, 3, 4, 5 1..^5 is 1, 2, 3, 4 1^..5 is 2, 3, 4, 5 1^..^5 is 2, 3, 4 There's also convenient shorthand for 0..^n (useful if you want to do something n times): ^n