title: python while loop range function
body: <p>Why can't while loop be used on a range function in python ?</p>
  
  <p>The code:</p>
  
  <pre><code>def main():
    x=1;
  
    while x in range(1,11):
       print (str(x)+" cm");
  
  
  if __name__=="__main__":
      main();
  </code></pre>
  
  <p>executes as an infinite loop repeatedly printing 1 cm</p>