title: A function to check for hill or valley in a given list, without usage of Numpy or zip?
body: <blockquote>
  <p>A list of numbers is identified as 'hill' if it has an ascending sequence followed by a descending sequence. Similarly, it'll be 'valley hill' if it consists of a descending sequence followed by an ascending one. Each of the sequences should be of length of at least two.</p>
  <p>For example, a list <code>[1,2,3,5,4]</code> will be a hill or a list <code>[5,4,1,2,3]</code> will be a valley.</p>
  </blockquote>
  <p>I'm trying to write a function, without the usage of either numpy arrays or zip function that returns a true if it identifies a hill or valley and false if it doesn't.</p>
  <p>The code I've come up with is:</p>
  <pre><code>def hillovalley(n):
    if len(n)&lt;=2:
      return False
    c = n[0]&lt;n[1]
    x=0
    for i in range(len(n)-1):
      if c!=(n[i]&lt;n[i+1]):
        c=n[i]&lt;n[i+1]
        x=x+1
      if x==1:
        return True
      else:
        return False
  </code></pre>
  <p>However, this code would fail if the input is something like <code>[1,2,3,5,4,3,2,1]</code> or <code>[9,5,4,-1,-2,3,7]</code>.</p>
  <p>Thank you for your help!</p>