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

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -