title: How to find unique elements in a list in python? (Without using set)
body: <blockquote>
    <p>Write a function that accepts an input list and returns a new list
    which contains only the unique elements (Elements should only appear
    one time in the list and the order of the elements must be preserved
    as the original list. ).</p>
  </blockquote>
  
  <pre><code>def unique_elements (list):
      new_list = []
      length = len(list)
      i = 0
      while (length != 0):
          if (list[i] != list [i + 1]):
              new_list.append(list[i])
          i = i + 1
          length = length - 1
      '''new_list = set(list)'''
      return (new_list)
  
  #Main program
  n = int(input("Enter length of the list: "))
  list = []
  for i in range (0, n):
      item = int(input("Enter only integer values: "))
      list.append(item)
  print ("This is your list: ", list)
  result = unique_elements (list)
  print (result)
  </code></pre>
  
  <p>I am stuck with this error:</p>
  
  <blockquote>
    <p>IndexError: list index out of range</p>
  </blockquote>