Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy re is not compiling 'if' when there is 'else'?
    primarykey
    data
    text
    <p>Hello I'm facing a problem and I don't how to fix it. All I know is that when I add an <em>else</em> statement to my <em>if</em> statement the python execution always goes to the <em>else</em> statement even there is there a true statement in <em>if</em> and can enter the <em>if</em> statement. </p> <p>Here is the script, without the else statement:</p> <pre><code>import re f = open('C:\Users\Ziad\Desktop\Combination\MikrofullCombMaj.txt', 'r') d = open('C:\Users\Ziad\Desktop\Combination\WhatsappResult.txt', 'r') w = open('C:\Users\Ziad\Desktop\Combination\combination.txt','w') s="" av =0 b="" filtred=[] Mlines=f.readlines() Wlines=d.readlines() for line in Wlines: Wspl=line.split() for line2 in Mlines: Mspl=line2.replace('\n','').split("\t") if ((Mspl[0]).lower()==(Wspl[0])): Wspl.append(Mspl[1]) if(len(Mspl)&gt;=3): Wspl.append(Mspl[2]) s="\t".join(Wspl)+"\n" if s not in filtred: filtred.append(s) break for x in filtred: w.write(x) f.close() d.close() w.close() </code></pre> <p>with the <em>else</em> statement and I want <em>else</em> for the <em>if</em> ((Mspl[0]).lower()==(Wspl[0])):</p> <pre><code>import re f = open('C:\Users\Ziad\Desktop\Combination\MikrofullCombMaj.txt', 'r') d = open('C:\Users\Ziad\Desktop\Combination\WhatsappResult.txt', 'r') w = open('C:\Users\Ziad\Desktop\Combination\combination.txt','w') s="" av =0 b="" filtred=[] Mlines=f.readlines() Wlines=d.readlines() for line in Wlines: Wspl=line.split() for line2 in Mlines: Mspl=line2.replace('\n','').split("\t") if ((Mspl[0]).lower()==(Wspl[0])): Wspl.append(Mspl[1]) if(len(Mspl)&gt;=3): Wspl.append(Mspl[2]) s="\t".join(Wspl)+"\n" if s not in filtred: filtred.append(s) break else: b="\t".join(Wspl)+"\n" if b not in filtred: filtred.append(b) break for x in filtred: w.write(x) f.close() d.close() w.close() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload