4.7 6 powers of two python
CodeHS is a comprehensive teaching platform for helping schools teach computer science. We provide web-based curriculum, teacher tools and resources, and professional development. All questions or comments related to CodeHS can go here! 0 points about 7 years my_list = [0,1,2,3,6,5,7] for i in range(0,len(my_list),2**i): print my_list[i] this code gives an error Answer 55e1c6b5d3292fba3e0000c2The code is fine apart from the for loop line. Read that line again.
This is how they should have gone:
As you can see, in your case, points about 7 years Answer 55e28f289113cb1cd400054dpoints about 7 years Answer 55e3b13b937676a569000576Try the following: import math l = list(range(0,100)) for i in range(0, int(math.log(len(l),2))+1): print l[2**i - 1] Note that the last line is indented but does not show in the preview. points about 7 years best way with powers of 2 is using bit-shifting on That said, I wouldn't recommend a
result:
|