title: python nested loop hailstone sequence for range
body: <p>Here is the assignment:In your program you will verify this conjecture in a user defined range. You will prompt the user to enter the first number of the range and the last number. You will then check if both numbers are positive (> 0) individually and that the first number in the user defined range is less than or equal to the last number in that range. If any one or more of those conditions fail keep prompting the user to input positive numbers in the right order.</p>
  
  <p>Once the beginning and ending of the range have been verified, your program will compute the cycle length for each of the numbers in that range inclusive of the end points. Your program will print out the number that has the largest cycle length and what that cycle length is.</p>
  
  <p>Your sample session will look like this:</p>
  
  <pre><code>Enter starting number of the range: 1
  
  Enter ending number of the range: 5
  </code></pre>
  
  <p>The number 3 has the longest cycle length of 7.
  In your program all your computations will be in the function <code>main()</code>. You must use nested loops to obtain your results.</p>
  
  <p>here is what I have:</p>
  
  <pre><code> def main(): 
   #prompt user to enter starting number of range
       lo = int (input("Enter starting number of the range: "))
   #prompt user to enter starting number of range again if input was negative
       while (lo &lt; 1):
          print("Error, enter positive number")
          lo = int(input("Enter starting number of the range: "))
   #prompt user to enter ending number of range
       hi = int(input("Enter ending number of the range: "))
   #prompt user to enter ending number of range again if input was negative
       while (hi &lt; 1):
          print("Error, enter positive number")
          hi= int(input("Enter ending number of the range: "))
   #set max cycle length and max number
       max_n = 0
       max_length = 0
   #Iterate all numbers in the range
       for n in range(lo, hi + 1):
        cycle_length = 0
        while (n != 1):
            if (n % 2 == 0): 
              n = n/2
              max_length += 1
              cycle_length = len(n)
            else:
              n = 3 * n + 1
              max_length += 1
              cycle_length = len(n)
            if n == 1:
              print (n)
        if (cycle_length &gt; max_length):
            max_length = cycle_length
            max_n = n
   #print output
       print('The number', max_n, 'has the longest cycle length of', str(max_length))
  </code></pre>
  
  <p>there is a logic error in here somewhere that i cannot find. 
  when i try to call it into python, it just skips a line and ignores my file.</p>
  
  <p>thanks for your help!</p>