I have a list that has 500 items and I want to get every item that is equal to 2 to the x power to be renamed False.
The best I could come up with is this
items = 
x = 2
for i in range(0,9):
for i in range(0,len(items)):
if i+1 == 2**x:
items[i] = False
x += 1
Please help, thank you!
items = [123,234,100,50, 64, 25,4,22,32,45,16, 9] x = max(items) def maxof2(x): for i in range(0,9): # You can choose the range based on the max value in the list if 2**i < x: continue else: return(i) twopowers = [2**x for x in range(0,maxof2(x))] for i in range(len(twopowers)): if twopowers[i] in items: items[i] = False items
[123, 234, False, 50, False, False, 4, 22, 32, 45, 16, 9]