I’ve noticed the following code is legal in Python. My question is why? Is there a specific reason? n = 5 while n != 0: print n n -=...
  • May 10, 2022
  • 0 Comments
This was an interview question asked by a senior manager. Which is faster? while(1) { // Some code } or while(2) { //Some code } I said that both...
  • April 30, 2022
  • 0 Comments
I am having trouble coming up with the right combination of semicolons and/or braces. I’d like to do this, but as a one-liner from the command line: while [...
  • April 23, 2022
  • 0 Comments
I need to emulate a do-while loop in a Python program. Unfortunately, the following straightforward code does not work: list_of_ints = [ 1, 2, 3 ] iterator = list_of_ints.__iter__()...
  • April 16, 2022
  • 0 Comments
Use break: while (true) { .... if (obj == null) { break; } .... } However, if your code looks exactly like you have specified you can use a...
  • April 3, 2022
  • 0 Comments