Can someone explain to me why this produces only 5,4 and not 5,4,3? num = 5 if num > 2: print num num -= 1 print num I would have thought once the loop got to 3, it's still greater than 2, so it would print the 3?
There is no loop. Maybe you meant to write "while" instead of "if"
Thanks, not feeling particularly well and jumping ahead of myself. I knew it was something simple. Thanks :)
It happens to all of us! Always good to have someone else read your code
Thanks for such a quick reply. I was hoping someone would be able to look at it right away. That's what I like about Open Study. Do you find it's "always" that quick?
Certainly not all programming problems are that quick, but many are caused by small oversights. Perhaps it's because I'm not an expert programmer, but I find most of my errors arise from foolish things leading to operations on null variables.
Join our real-time social learning platform and learn together with your friends!