title: loop finding "bouncy" numbers
body: <p>Consider the following definitions of positive numbers:</p>
  
  <p>A number is nondecreasing if its digits never get smaller as you go from left to right. For example, 12345
  and 3388 are nondecreasing.</p>
  
  <p>A number is nonincreasing if its digits never larger as you go from left to right. For example, 987542 and
  881 are nonincreasing.</p>
  
  <p>A number is bouncy if it is neither nondecreasing nor nonincreasing. For example, 12134 and 98462 are
  bouncy.
  Write a Python function bouncy that consumes a positive natural number (called n) and produces the
  percentage of numbers between 1 and n, inclusive, which are bouncy. The result should be produced as a
  natural number between 0 and 100, inclusive. Use round to convert the floating point percentage to an
  integer. </p>
  
  <pre><code>def bouncy(input):
  list1 = [0 for i in range(input)]
  list1[0] = 0
  for x in range(1, input-1):
      if x &lt; 100:
          list1[x] = list1[x - 1]
      else:
          n=x
          a = [0 for i in range(x)]
          i = 0
          while n &gt; 0:
              a[i]=n % 10
              n/= 10
              i+=1
          flag = 1
          for k in range(1, len(a) - 2):
              if not ((a[k - 1] &lt; a[k] &lt; a[k + 1]) or (a[k - 1] &gt; a[k] &gt; a[k + 1])):
                  flag = 0
                  break
          if flag == 0:
              list1[x]==list[x-1]+ 1
  return list1[input-1]
  </code></pre>
  
  <p>when i ran my code, it displays <code>builtins.IndexError: list assignment index out of range</code>. </p>
  
  <p>Anyone got an idea?</p>