You are viewing a single comment's thread. Return to all comments →
I disagree, 1-based indices are most frequent in the real world and it's useful to keep the habit to juggle with that.
(All you have to do is to add +1 to each of the indices in the print statement, not a big deal !)
It's also most common in applications that you search for an item by its price or name etc but you want to get the id of it.
The confusin thing is that this problem is tagged "binary search" while that search is hidden in the dictionary lookup implemented by the system, at least if one has dict/map or equivalent as part of the language.