var n = i+1?i<length:length;Ternary expressions almost always have the structure:
condition value_if_true value_if_falseMy Python brain got it wrong, as you can see, I used:
i+1 if i < length else lengthStupid Python. In this case, The language syntax of Python should have followed the conventions used by most of the planet. "Practicality beats Purity" and all that.
Edit:To be clear, my point is that the Python Ternary expression is needlessly different to almost every other language and causes Brain Pollution.