lundi 2 février 2015

Python 3: Remove items at positions 1,2,4,8,16,.. from list


Vote count:

0




How would I go about removing every element with index 2^x in a list? I've tried using a for loop with a variable representing x increasing by 1 in every loop but this throws the out of range error.


e.g:



remove([0,0,1,1,0,1,0,1,1])
>>>[1,0,1,0,1]


asked 1 min ago







Python 3: Remove items at positions 1,2,4,8,16,.. from list

Aucun commentaire:

Enregistrer un commentaire