Python: Changing indivividual elements in a list of bool -
i have list of bool below:
[false, false, false, false, false, false] i wish change last 2 elements (or indices of choice) true:
[false, false, false, false, true, true]
per comment, given arbitrary indices i , j (where i <= j) want set list[i:j] = true can following:
list = list[:i] + [true] * (j-i) + list[j:]
Comments
Post a Comment