I have this list
x = [1,2,3,4,5,6]
I would like to convert elements greater than 3 as 0 so the list would become [1,2,3,0,0,0]
Here is my code
for i in range(len(x)):
if x[i] > 3:
x = 0
I got this error message " 'int' object is not subscriptable". could somebody tell me what I did wrong
could somebody tell me what I did wrong: Look at your code and think about whatx = 0does.x > 3you set thelistx = 0from that point forward it is a number. You probably meantx[i] = 0