title: How Iterate or remove MongoDb array list item using pymongo?
body: <p>I want to iterate Mongodb database Arraylist items(TRANSACTION list)  and remove  Arraylist specific(TRANSACTION List) item using pymongo ?</p>
  
  <p><a href="https://i.stack.imgur.com/ya9Kk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ya9Kk.png" alt="enter image description here"></a></p>
  
  <p>I create Mongo collection as above using python pymongo. I want to iterate array list item using pymongo and remove final item only in Arraylist? </p>
  
  <p>Data insert query using Python pymongo</p>
  
  <pre><code> # added new method  create block chain_structure
      def addCoinWiseTransaction(self, senz, coin, format_date):
          self.collection = self.db.block_chain
          coinValexists = self.collection.find({"_id": str(coin)}).count()
          print('coin exists : ', coinValexists)
          if (coinValexists &gt; 0):
              print('coin hash exists')
              newTransaction = {"$push": {"TRANSACTION": {"SENDER": senz.attributes["#SENDER"],
                                                          "RECIVER": senz.attributes["#RECIVER"],
                                                          "T_NO_COIN": int(1),
                                                          "DATE": datetime.datetime.utcnow()
                                                          }}}
              self.collection.update({"_id": str(coin)}, newTransaction)
          else:
              flag = senz.attributes["#f"];
              print flag
              if (flag == "ccb"):
                  print('new coin mined othir minner')
                  root = {"_id": str(coin)
                      , "S_ID": int(senz.attributes["#S_ID"]), "S_PARA": senz.attributes["#S_PARA"],
                          "FORMAT_DATE": format_date,
                          "NO_COIN": int(1),
                          "TRANSACTION": [{"MINER": senz.attributes["#M_S_ID"],
                                           "RECIVER": senz.attributes["#RECIVER"],
                                           "T_NO_COIN": int(1),
                                           "DATE": datetime.datetime.utcnow()
                                           }
                                          ]
                          }
                  self.collection.insert(root)
              else:
                  print('new coin mined')
                  root = {"_id": str(coin)
                      , "S_ID": int(senz.attributes["#S_ID"]), "S_PARA": senz.attributes["#S_PARA"],
                          "FORMAT_DATE": format_date,
                          "NO_COIN": int(1),
                          "TRANSACTION": [{"MINER": "M_1",
                                           "RECIVER": senz.sender,
                                           "T_NO_COIN": int(1),
                                           "DATE": datetime.datetime.utcnow()
                                           }
                                          ]
                          }
                  self.collection.insert(root)
  
          return 'DONE'
  </code></pre>