Now you try! Question about parenthesis


So I just finished the problem, but was getting back an error about an incorrect length of the list.

cubes_by_four = [x**3 for x in range(1,11) if (x**3) % 4 == 0]

print cubes_by_four

I changed it to

cubes_by_four = [(x**3) for x in range(1,11) if (x**3) % 4 == 0]

print cubes_by_four

which allowed it to pass, but I don't see why it didn't just work in the first place. Were these parenthesis really needed?




was it just some unseen "magic" in the browser compiler?


Change it back and see if it makes any difference. Most likely you changed something else as well.

Python is typically seen as interpreted, not compiled. It does not run in your browser, it's sent off to a server (browser's don't typically sport a Python interpreter)


interesting! I wasn't aware it wasn't an inbuilt compiler -- I think the code was the same, but then again perhaps not. Thanks for the quick reply.


Changing it back would let you know. I'm saying it's probably a second change because it appears to be pretty common to not notice the other change, we focus one change and then we really want it to be the solution. I also have a bit of insight in how the submission tests work (written some of them even, only good ones, for the record.) and this doesn't look like it'll make any difference. It'll have no functional effect at all, and the submission test for that exercise doesn't "look" at the code, only at the state of the program afterwards.

It could be something that you don't consider a change, but it'll still be there. Something else.


I think maybe I changed something in the range() function, maybe I should take the git course next so I can track my changes XD