title: Alternatives to index() in Python
body: <p>So for my assignment I must find a way in which I can work around this problem of printing 'YES' if a list contains the elements 1,2,3 in the consecutive order. It does not work if the list contains the elements [3,1,2,3] due to the index method. How can I work around this? </p>
  
  <pre><code>n=int(input("Enter the number of elements: "))
  
  A=[]
  for i in range(0,n):
      print("Entering element", i)
      LstEl=int(input("Please enter the element: "))
      A.append(LstEl)
  
  
  print(A)
  for i in range(0,len(A)):
      if(1 in A and 2 in A and 3 in A):
          post1 = A.index(1)
          post2 = A.index(2)
          post3 = A.index(3)
          if(post1 &lt; post2 and post2 &lt; post3):
              print("YES")        
              break
          else:
              print('NO')
              break
      else:
          print("NO")
          break
  </code></pre>
  
  <p>Thanks!</p>