Closed MystPi closed 2 years ago
I agree that 0-indexing is not always worth it, and I would like to add an option for 1-indexing. However, IMHO it would be confusing for python []
notation to ever mean 1-indexing, especially if it was in the same source file as 0-indexed operations on normal python lists.
I think the best way to handle this is to create special methods for 1-indexing, eg something like my_list.oneindex(index)
- or perhaps my_list.item(index)
, to match the naming of the scratch block
I've added .item()
for lists and strings, along with .delete_at1()
and .index1()
for lists
Thank you! That helps a lot!
In some projects, 0-based indexes are more trouble than they're worth. They can also generate bugs like the following pseudocode:
Which gets turned into:
I propose an option to disable 0-based indexes. Here's an idea of how the interface might work: