title: "Python : class object doesnt support indexing" error
body: <p>I'm experimenting with classes, this is my first time applying them</p>
  
  <p>Here is the Class:</p>
  
  <pre><code>class CreateArray:
  
     def __init__(self):
          array = []
          self.array = array
          print('How many elements?')
          ele = int(input())
          for j in range(ele):
              print('Enter element '+str(j+1))
              uin = int(input())
              array.append(uin)
          print('Array elements are: ')
          print(array)
  
      def __len__(self):
          return len(self.array)
  </code></pre>
  
  <p>This here is a part of my program:</p>
  
  <pre><code>def comparedata(arr1, arr2):
      newlist = []
      arr1. __len__()
      if len(arr1) == len(arr2):
          for i in range(len(arr1)):
              if arr1[i] &gt; arr2[i]: #indexing error occurs here
                  newlist.append(arr1[i])
  
              elif arr1[i] &lt; arr2[i]:
                  newlist.append(arr2[i])
  
              print(newlist)
  
  
  print('array 1 data: ')
  arr1 = CreateArray()
  print('array 2 data: ')
  arr2 = CreateArray()
  print('The two arrays are: ')
  print(arr1.array)
  print(arr2.array)
  print('The greatest elements between the two arrays are: ')
  comparedata(arr1,arr2)
  </code></pre>
  
  <p>I get an error at <code>if arr1[i]&gt;arr2[i]</code>:</p>
  
  <blockquote>
    <p>CreateArray object doesn't support indexing</p>
  </blockquote>
  
  <p>due to which the function call doesn't get executed</p>