Given a list lst, write a 'for' loop that replaces each element of lst with alternating 0's and 1's, starting with 0. For example, if lst is [5, 3, 7, 0], it should become [0, 1, 0, 1], and if lst is [1, 2, 3], it should become [0, 1, 0] *

Respuesta :

Explanation:

c++:

for(int i =0;i<list.size();i++){

list[i]=i%2;

}

python 3:

for i in range(len(list)):

list[i]=i%2