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

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -

Qt4: how to send QString inside a struct via QSharedMemory -