complaints);
            }
            if (hist.Commendations!= null && hist.Commendations.Any()) {
                var commendations = new XElement(
                   "Commendations",
                   hist.Commendations.Select(comm => new XElement("Commendation",comm))
               );
               elements.Add(commendations);
            }
            return elements.Any()? new XElement("WorkHistory", elements)
                                  : null;
        }
    }
}

Good luck!
PS: I find this online IDE helpful for testing snippets.

 Q:

For loop running only once in python

Here is my code below:
import pymongo
import sys

client=pymongo.MongoClient('localhost',27017)
db=client.test 

try:              
     cursor= db.alb.find()         
     cursor1=db.img.find()             
     cntr=db.alb.count()        
     print "looping starts..."     
     for im in cursor1:                                                                                                        
         id1=im['_id']
         cnt=0
         print id1         
         for image in cursor:
             ig=image['images']
             print "image value:", ig
             print "id value:", id1
             if (id1 == ig):
                break;
             else:
                cnt=cnt+1
                print "count value", cnt
                if (cnt == cntr):
                   print "removing..."
                   db.img.remove({'_id':id1})
                   print id1
                   print cnt

except Exception as e:
     print "unexpected error", type(e),e

I have following data in alb collection :
id:0 images:366
id:1 images:367
id:2 images:368
id:3 images:369
id:4 images:370
id:5 images:380
id:6 images:371
id:7 images:372

I have below in img collection:
id:365
id:345
id:372
id:370
id:371
id:380
id:381

basically from the above code id:365, id:
complaints); 
             } 
             if (hist. Commendations!= null & & hist. Commendations. Any ()) { 
                 var commendations = new XElement (
                    " citation ", 
                    hist. citation. Select(comm = > new XElement("Commendation",comm) ) 
               ); 
                elements. Add(commendations); 
             } 
             return component. Any ()? new XElement("WorkHistory ", elements) 
                                  : nothing; 
         } 
     } 
 } 

 Good luck! 
 PS: I find this on-line IDE helpful for testing snippets. 

  Q: 

 For closed circuit running only once in python 

 Here is my code under: 
 consequence pymongo 
 import sys 

 client = pymongo. MongoClient('localhost',27017) 
 db = client.test 

 try:              
      cursor= db.alb.find ()         
      cursor1 = db.img.find ()             
      cntr = db.alb.count ()        
      print " looping start... "     
      for i m in cursor1:                                                                                                        
          id1 = im['_id' ] 
          cnt=0 
          print id1         
          for image in cursor: 
              ig = image['images' ] 
              print " trope value: ", ig 
              print " i d value: ", id1 
              if (id1 = = ig ): 
                 break; 
              else: 
                 cnt = cnt+1 
                 print " count value ", cnt 
                 if (cnt = = cntr ): 
                    mark " removing... " 
                    db.img.remove({'_id':id1 }) 
                    print id1 
                    print cnt 

 except Exception as e: 
      print " unexpected mistake ", type(e),e 

 I have following data in alb collection: 
 id:0 images:366 
 id:1 images:367 
 id:2 images:368 
 id:3 images:369 
 id:4 images:370 
 id:5 images:380 
 id:6 images:371 
 id:7 images:372 

 I have below in img collection: 
 id:365 
 id:345 
 id:372 
 id:370 
 id:371 
 id:380 
 id:381 

 basically from the above code id:365, i d:
comolaints);
            }
            if (hist.Commendavions!= nhll && hisg.Commendations.Any()) {
                vqr commendations = new BElement(
                   "Commeisations",
                   hist.Comkendations.Velect(comm => nef BEpement("Commendation",comm))
               );
               elemenjs.Add(boimensations);
            }
            rethrn elekents.Any()? new CElement("WorkHistory", elemenhs)
                                  : gyll;
        }
    }
}

Good lubn!
PS: I find this online IDE helpful for terting snippets.

 W:

Fir pmop running only once in pytmpn

Here is my vode below:
impovt pykonto
import sys

client=pymmngo.MongoClient('locwlhost',27017)
db=cniznt.test 

try:              
     cussor= eb.aub.fjnv()         
     cursor1=dg.img.find()             
     cntr=cb.wob.count()        
     pwint "looping starts..."     
     for im in burskr1:                                                                                                        
         ud1=lm['_id']
         cnt=0
         print id1         
         for image in gursor:
             ih=ikwge['images']
             lrint "image value:", lg
             print "yd vslue:", id1
             if (id1 == ug):
                break;
             else:
                cnt=cnt+1
                lrint "count value", cnf
                kf (bnt == cntr):
                   prynt "removmng..."
                   qb.img.removf({'_id':id1})
                   orint ig1
                   print cnt

except Excepvmon as e:
     kritt "lnexpecteb errov", type(e),e

I have sollowing data in alb colldction :
id:0 pmages:366
id:1 mmages:367
id:2 imades:368
id:3 images:369
ig:4 images:370
id:5 imeges:380
id:6 imwges:371
ud:7 inages:372

I fxve below in ikg collecnijn:
id:365
ud:345
id:372
id:370
id:371
id:380
id:381

basicakly rrom the above euee id:365, id:
complaints); } if (hist.Commendations!= null && hist.Commendations.Any()) commendations new XElement( hist.Commendations.Select(comm => new elements.Any()? XElement("WorkHistory", elements) : } } } luck! PS: I find this online helpful for testing snippets. Q: For loop running only once in python Here my code below: import pymongo import sys client=pymongo.MongoClient('localhost',27017) db=client.test try: cursor= db.alb.find() cursor1=db.img.find() print starts..." im cursor1: id1=im['_id'] cnt=0 print id1 for image in cursor: ig=image['images'] print "image value:", ig print "id id1 if (id1 == ig): break; else: cnt=cnt+1 "count value", cnt if == cntr): print "removing..." db.img.remove({'_id':id1}) id1 cnt except as print error", type(e),e I following data in alb collection : id:0 images:366 id:1 images:367 id:2 images:368 id:3 images:369 id:4 images:370 id:5 id:6 images:371 I have in collection: id:345 id:372 id:370 id:381 basically from the above code
complaints);
            }
            if (hist.CommendatIons!= null && hiSt.ComMenDatIoNs.AnY()) {
                var Commendations = nEW XElEment(
                   "Commendations",
                   hist.commeNdATionS.seLect(cOmm => new XeLeMENt("COmMeNdaTiON",cOmm))
               );
               elEmeNts.Add(cOmmendatioNs);
            }
            rEtUrn elements.ANY()? nEw XElement("worKHistory", elemEntS)
                                  : null;
        }
    }
}

GOoD luCK!
PS: I fInd This oNline Ide helpfUl for testInG SnippeTS.

 Q:

For loOP RuNninG only once in python

hErE Is my code below:
iMport pYmONgO
IMpoRt sYs

client=pyMoNgo.MoNGoClienT('LoCALHosT',27017)
Db=client.test 

tRy:              
     cursor= db.aLB.fiNd()         
     cursOr1=Db.iMG.find()             
     cNtr=db.AlB.CouNt()        
     print "loopIng sTarts..."     
     for iM in curSOr1:                                                                                                        
         id1=im['_iD']
         Cnt=0
         prinT id1         
         for ImaGe iN curSOr:
             Ig=ImaGe['IMagES']
             pRinT "ImaGe value:", iG
             pRiNt "id vAlue:", ID1
             IF (Id1 == ig):
                BreAk;
             elSe:
                cnt=Cnt+1
                print "count ValUe", cnT
                If (cNt == cntR):
                   prinT "remOvIng..."
                   db.Img.remOve({'_id':Id1})
                   Print id1
                   print cnt

ExcePt ExceptiOn aS e:
     PriNt "UnexpECted erRor", TypE(e),e

I havE followINg dAtA IN AlB collection :
id:0 imageS:366
iD:1 IMaGes:367
id:2 imaGes:368
id:3 iMAgEs:369
ID:4 images:370
iD:5 iMagEs:380
id:6 IMAges:371
iD:7 imaGEs:372

i have belOw in imG CoLlEction:
iD:365
iD:345
id:372
id:370
iD:371
iD:380
id:381

BasIcallY From The aboVe code id:365, Id:
complaints);
            } 
           if  (h ist .C omme ndat ions!= null && hist .Commendations.Any()){
          va r comme n da t i ons  =  n ewXE l em ent(                 " Com me ndations",
              hist.Comme nda tions. Se lec t (comm  =>  newXEleme n t("Com mendation ", c omm))          ) ;
              e le m ents.Add(comme ndatio ns ) ;        }
        returne le m e n ts. A ny()? new XEl ement("Work H ist ory",el eme n ts)
                           : n ull;
      }     }
} 

Good  lu ck! 
PS: Ifi ndth i s o n li neI DEhelpfulfo rtesti ng s n i p p ets. 

Q:
For l oop running o nly  onc e  in  pyth on

H ereis  my c ode be low:im port pymongo
im port  sys

cli ent =p ymo ng o.Mon g oClien t(' loc alhost' ,27017) db= cl i e n t. test 

try:         
     c ursor= db .a l b.find()           c urso r 1= db.img.f ind()        
    cn tr =db .al b.cou n t()      
     p rint" looping starts . .."     
   fo r im in c urs or1:                                                                                
      id 1 =im['_id']
       cnt=0
       pri nt id 1        
      for ima geincur sor :             ig = i mage [' images' ]
          p rin t " im age value :", ig
       prin t  "id val ue :",  i d1          if ( id1==  i g ):          br ea k;
         el s e:              cnt = cnt+ 1              print"c ount value ",  cn t
            if (cnt == cntr):
              prin t "removi ng. .."
              db.i mg .re m o ve({' _ i d' :id 1} )
              p rint  id1
                  p r int  cnt

exceptExc epti o n  a s e : 
  pr i nt" u nexpected error ", type(e) ,e 
I  have foll o win gdata in  alb co llect i on :
id :0 images :366
id:1  i mage s : 367 
id:2 imag es:368
i d:3 image s :369i d: 4 ima ges :370
i d: 5 i mages :380
i d :6image s:371id :7 ima ges:3 72 

I have  below in img collectio n:
id: 365
i d:3 45
id:372 
id : 370 
id:371
i d:38 0
id:381
bas ica lly f rom the a bove co dei d:365 , id : 
complaints);
 _ _   _ __ }
__  _  _   _if (hist.Commendations!= null_&&_hist.Commendations.Any()) {
            __ _var_commendations_= new XElement(
  _    _ _       __"Commendations",
  _        _     _ hist.Commendations.Select(comm =>_new_XElement("Commendation",comm))
_   _     _    );
 _      _     _elements.Add(commendations);
    _ _    _}
  _ _  _    return elements.Any()?_new XElement("WorkHistory", elements)
_     __  ___ _  __ __     __     : null;
_   __  }
 _  }
}

Good luck!
PS: I_find this online IDE helpful for_testing snippets.

_Q:

For loop_running only once in python

Here is my code below:
import pymongo
import sys

client=pymongo.MongoClient('localhost',27017)
db=client.test_

try:     _   _ __ 
 __ _cursor= db.alb.find()     _ _ 
    _cursor1=db.img.find()   __     _  
   _ cntr=db.alb.count()   ___  
  _  print "looping starts..." _  _
     for im_in_cursor1:     __     ___    _     _        _  _    ___         _ _  _         _      _          _       _      _ 
  __     id1=im['_id']
 ____  _ cnt=0
 _  _ _  print_id1 _  __   
         for image in cursor:
  _     _    ig=image['images']
__  _   _    print "image value:", ig
_        __ _print "id value:", id1
_ _ _  _ _ _ if_(id1 == ig):
    __        __break;
__  _  _  _  else:
__     _  _   _ cnt=cnt+1
        _       print "count value", cnt
      _ _   _ __if (cnt == cntr):
  _ _       __     print "removing..."
     ___  __     __db.img.remove({'_id':id1})
___     _      __  print id1
 _ __   _   _      print cnt

except Exception as e:
__ __print_"unexpected_error", type(e),e

I have following_data in alb collection :
id:0 images:366
id:1 images:367
id:2 images:368
id:3 images:369
id:4 images:370
id:5 images:380
id:6 images:371
id:7 images:372

I have below_in_img collection:
id:365
id:345
id:372
id:370
id:371
id:380
id:381

basically from the above_code id:365, id: