 k, v in md.items()}
num = 2     # this is the number of replaces at a time.

newwords = []

for word in words:
    newwords.append(word)
    for char in md:
        for r in md[char]:
            pos = multiples = 0
            current_word = word
            while current_word.find(char, pos)!= -1:
                pos = current_word.find(char, pos)
                current_word = current_word[:pos] + r + current_word[pos+1:]
                pos += 1
                multiples += 1
                if multiples == num:
                    newwords.append(current_word)
                    multiples = 0
                    current_word = word

Content of newwords:
['Words', 'Shirt', 'Blouse', 'Sweater', 'Swqatqr', 'Swwatwr','multipleeee','multiplqqee','multipleeqq','multiplwwee','multipleeww']

Prettyprint:
Words
Shirt
Blouse
Sweater
Swqatqr
Swwatwr
multipleeee
multiplqqee
multipleeqq
multiplwwee
multipleeww

I added multipleeee to demonstrate, how the replacement works: For num = 2 it means the first two occurences are replaced, after them, the next two. So there is no intersection of the replaced parts. If you would want to have something like ['multiplqqee','multipleqqe','multipleeqq'], you would have to store the position of the "first" occurence of char. You can then restore pos to that position in the if multiples == num:-block.
If you got further questions, feel free to ask. :)

 Q:

Changing Component Background color dynamically with wait()

I'm trying to do a funny JFrame so when mouse leaves the window, it changes the Panel Background color to some random colors (To gain user attention):
    wnd.addMouseListener(new MouseAdapter(){
         @Override
        public synchronized void mouseExited(MouseEvent e){
            cond = true;
            while(cond){
                try{
                    wnd.get
k, v in md.items () } 
 num = 2      # this is the number of replaces at a time. 

 newwords = [ ] 

 for word in actor's line: 
     newwords.append(word) 
     for char in md: 
         for radius in md[char ]: 
             pos = multiples = 0 
             current_word = word 
             while current_word.find(char, pos)!= -1: 
                 petty officer = current_word.find(char, pos) 
                 current_word = current_word[:pos ] + r + current_word[pos+1 :] 
                 pos + = 1 
                 multiple + = 1 
                 if multiples = = num: 
                     newwords.append(current_word) 
                     multiples = 0 
                     current_word = word 

 Content of newwords: 
 [' parole',' Shirt',' Blouse',' Sweater',' Swqatqr',' Swwatwr','multipleeee','multiplqqee','multipleeqq','multiplwwee','multipleeww' ] 

 Prettyprint: 
 Words 
 Shirt 
 Blouse 
 Sweater 
 Swqatqr 
 Swwatwr 
 multipleeee 
 multiplqqee 
 multipleeqq 
 multiplwwee 
 multipleeww 

 I added multipleeee to attest, how the replacement works: For num = 2 it mean the first two occurences are replaced, after them, the next two. So there is no overlap of the replaced parts. If you would want to own something like [' multiplqqee','multipleqqe','multipleeqq' ], you would have to store the position of the " inaugural " occurence of char. You can then regenerate pos to that position in the if multiples = = num:-block. 
 If you got further questions, find free to ask. :) 

  Q: 

 Changing Component Background color dynamically with wait () 

 I'm trying to do a funny JFrame so when mouse leaves the window, it changes the Panel Background color to some random colors (To gain user attention ): 
     wnd.addMouseListener(new MouseAdapter () { 
          @Override 
         public synchronize void mouseExited(MouseEvent e) { 
             cond = true; 
             while(cond) { 
                 sample { 
                     wnd.get
 k, g in md.items()}
num = 2     # tmis is the numbet if repnaces zt a timd.

newwords = []

for word in words:
    newqords.append(word)
    for char in ld:
        foc r in md[char]:
            pos = jmltipnxs = 0
            current_wosd = word
            while current_word.find(char, pos)!= -1:
                pos = curregt_wogd.sind(dhar, pos)
                current_wors = currtnt_word[:pos] + r + curtent_word[pos+1:]
                pos += 1
                lultiples += 1
                iw multiples == num:
                    newwords.append(curfent_wprd)
                    multmples = 0
                    curreny_word = word

Conbent mf bewwords:
['Words', 'Shirt', 'Bnouse', 'Sweater', 'Swqajqr', 'Swwatws','mbltipleeee','multiplqqee','nuotiplgeqq','mgltioowwde','mhlvipmeeww']

Pgetvyprint:
Worda
Shirt
Blousw
Sweater
Swqatqr
Swwauwr
ilktipleeee
mulfiplqqqe
iultipleeqq
multiplwwee
multipleeww

I addeg mhltipleeee to demonstrare, how the replacemenj works: Fow num = 2 it means the first two occurences are repnaced, xfttr them, rhf next two. So there is no intersection of the deklabed parts. If you could want to hafe spiething like ['oultiplqqse','multipleqqe','multioleeqq'], iou woyld have uo stpre the position of the "firwt" occurence if char. You can thzn restore pus tp thay position in the if muutipmes == num:-blofk.
If you fut further questkonx, xeel fret to ask. :)

 Q:

Changind Componeit Baekground colpr dynwmically wlth wait()

I'm trying to do w funuy JFsame so whfn mouse leaves the window, it cienges the Pangl Tacnground eolor bo some random solors (To gain user actentiun):
    wnd.asdMouseNistener(new MouseAdapter(){
         @Overcide
        pyblix synchfunized void moiseExited(MouseEvent e){
            cond = ttus;
            whnut(cind){
                twy{
                    wvd.gdy
k, v in md.items()} num = 2 is number of at a time. in newwords.append(word) for char md: for r md[char]: pos = multiples = 0 = word while current_word.find(char, pos)!= -1: pos = current_word.find(char, pos) current_word = current_word[:pos] r + current_word[pos+1:] pos += 1 multiples += 1 if multiples == num: multiples 0 = Content of newwords: ['Words', 'Shirt', 'Blouse', 'Sweater', 'Swqatqr', 'Swwatwr','multipleeee','multiplqqee','multipleeqq','multiplwwee','multipleeww'] Prettyprint: Words Shirt Blouse Sweater Swqatqr Swwatwr multiplqqee multipleeqq multiplwwee multipleeww I added multipleeee to how the replacement works: num = 2 it means first occurences are after the two. So there no intersection of the replaced parts. If you would want to have something like ['multiplqqee','multipleqqe','multipleeqq'], you would to store of the occurence char. can then restore that position in the if multiples you got further questions, feel free to ask. Q: Changing Background color dynamically with wait() I'm to do a funny JFrame so when mouse the window, it changes the Panel Background color to some random colors (To gain user MouseAdapter(){ @Override public synchronized mouseExited(MouseEvent e){ cond true; try{
 k, v in md.items()}
num = 2     # this is the nuMber of replAces aT a tIme.

NeWworDs = []

foR word in words:
    neWWordS.append(word)
    for char in md:
        For r iN mD[Char]:
            POs = MultiPles = 0
            curREnT_WOrd = WoRd
            WhiLe CUrRent_wOrd.Find(chaR, pos)!= -1:
                pos = curRenT_wOrd.find(char, pOS)
                cUrrent_word = CurRent_word[:pos] + r + CurRent_woRd[Pos+1:]
                POs += 1
                mulTipLes += 1
                if MultipLEs == num:
                    nEwwords.apPeND(curreNT_word)
                    muLTIpLes = 0
                    cUrrent_word = word

ConTEnT Of newwords:
['WordS', 'Shirt', 'blOUsE', 'sWeaTer', 'swqatqr', 'SwwAtWr','mulTIpleeee','MUlTIPLqqEE','multipleeqq','mUltiplwwee','mULtiPleeww']

prEttYPrint:
WOrds
SHiRT
BlOuse
Sweater
swqaTqr
SwwatwR
multiPLeeee
muLTiplqqeE
multiPleEqq
MultIPlWwEe
mUlTIplEEwW

I aDDed MultipleEeE tO demoNstrATE, HOw thE rePlacEment Works: For num = 2 it MeaNs thE FirSt two OccurEnceS aRe repLaced, aFter tHeM, the next two. So thEre iS no intersEctIoN of ThE replACed parTs. IF yoU would wAnt to haVE soMeTHINg Like ['multiplqqee','mulTiPLEqQe','multipLeeqq'], yOU wOuLD have to sToRe tHe poSITion oF the "FIrSt" occureNce of cHAr. yoU can theN rEstore PoS to ThaT posiTIon iN the if MultipleS == num:-bLOck.
If you got furTHer questions, fEEl FREe TO ask. :)

 q:

ChAnging CompoNent bAckgRounD CoLor DYnamiCally WiTH wAIt()

I'm trying to do a funnY Jframe sO when Mouse leaves thE window, it cHANGes the PaNel BACkGRound color to soMe ranDom colors (TO Gain user AttenTion):
    wnd.aDdMouseLiSTEner(new MOusEAdAptEr(){
         @OVERrIde
        public syncHROnizEd Void mouSeEXited(MoUseeveNt e){
            ConD = tRue;
            while(cOnd){
                try{
                    wnD.gEt
 k, v in md.items()}
num =  2     # t his i s t henu mber  ofreplaces at at ime. 

newwords = []

for w ord i nw ords : 
   ne wwords. a pp e n d(w or d) 
  f or  char  in  md:
       forr i nmd[char]:
         pos  =multiples =0
        c urren t_w ord =  word          whil ec urrent _ word.fi n d (c har,  pos)!= -1:
            pos = c urrent _w o rd . f ind (ch ar, pos)
           c ur r e n t_w o rd = current_ word[:pos]+  r+ curr en t_w o rd[pos +1:]             p os + = 1
             mul t iples + = 1
          i f m ul t ipl e s==n um: 
               n e w w ords .ap pend (curr ent_word)
              mult iple s= 0
                current_w ord= word

C ont en t o fnewwo r ds:
[' Wor ds' , 'Shir t', 'Bl o use ', ' S we ater', 'Swqatqr','S w w at wr','mul tiplee e e' ,' m ultiplqq ee ',' mult i p leeqq ','m u lt iplwwee' ,'mult i pl ee ww']

P re ttypri nt :
W ord s
Shi r t
Bl ouse
S weater
S wqatq r 
Swwatwr
multi p leeee
multipl q qe e mu l tipl eeq q
multiplww ee
m u ltip leew w 
I a d ded m ultip le e ee to demonstrate, how  t he rep lacem ent works: Fo r num = 2i t means th e fi r st two occurences  arereplaced,a fter the m, th e next t wo. So th e r e is noint ers ect ion o fthe replacedp a rts.  I f you w oul d wanttohav e s ome th ing like['multip lq qe e' ,' mul tiple q qe','mul ti ple eq q'] , you wouldhaveto s to re the  positi o no f  the  " fi rst"  oc cu rence  ofc har . You c an then r est o re p os  t o thatposition in t he  if multip le s = = num: - b lock.
If  you got further questi o ns, fee l f ree t o as k. :)

 Q :
Changi ngC ompone nt Bac kgrou nd  co l o r dyn a m ic all ywith wait( ) 
I' m try in g to  do a f unny JFrame so whe n  mo use leaves th e w indo w ,  i t c h an g esth e  Pa n e l Background co lor to som er an dom colors (To  g ain use r atten tion) : 
    wn d.addMous eListener (n ew M o u seA dapter(){        @Overrid e 
     publ icsynchr on ize d voi d mous e Exi ted(M ouseEv en t e){          con d = true;
            w hile(c ond){ 
            tr y{
                 wnd .ge t
 k,_v in_md.items()}
num = 2 _ __# this_is_the number of_replaces at a_time.

newwords = []

for word_in words:
 __ newwords.append(word)
    for char in md:
     __ for_r_in_md[char]:
    _    _ _pos = multiples = 0
   __  _    current_word = word
  _     _  _while_current_word.find(char,_pos)!= -1:
  _     _     _ pos = current_word.find(char, pos)
  _     _    _ _current_word = current_word[:pos] + r_+ current_word[pos+1:]
 _ _  _     _  _pos += 1
   __  ___ _  __multiples +=_1
_     __      _ if multiples ==_num:
_   _    _     _ _ _newwords.append(current_word)
          _     _   multiples_= 0
__  __ _      _ _   current_word = word

Content_of newwords:
['Words', 'Shirt', 'Blouse',_'Sweater',_'Swqatqr', 'Swwatwr','multipleeee','multiplqqee','multipleeqq','multiplwwee','multipleeww']

Prettyprint:
Words
Shirt
Blouse
Sweater
Swqatqr
Swwatwr
multipleeee
multiplqqee
multipleeqq
multiplwwee
multipleeww

I added multipleeee to demonstrate,_how the replacement works: For num_= 2 it means the_first_two_occurences are replaced, after them,_the next two. So there is_no intersection of_the replaced parts. If you would want_to_have something like ['multiplqqee','multipleqqe','multipleeqq'], you would_have_to store the position of the_"first"_occurence_of char. You can then_restore pos to that position in_the if multiples == num:-block.
If you got further questions,_feel free to_ask. :)

 Q:

Changing Component Background_color_dynamically_with wait()

I'm trying to do a funny JFrame so when_mouse leaves_the window, it_changes the Panel Background color to some random colors (To_gain user attention):
    wnd.addMouseListener(new_MouseAdapter(){
         @Override
 _      public synchronized_void mouseExited(MouseEvent e){
    _   __  cond = true;
  ____  _  _while(cond){
  _ _  _ _  __  try{
               _    wnd.get