Why some part of code is not participate in execution process <p>I am trying to split network into two groups (g1 and g2) according to the degree of nodes (if degree of node d>=691 then node is add in g1 otherwise node is add in g2) </p> <pre><code>import networkx as nx import random import numpy as np import os import sys from networkx.algorithms.assortativity.mixing import degree_mixing_matrix # \attribute_mixing_matrix, numeric_mixing_matrix from networkx.algorithms.assortativity.pairs import node_degree_xy #, \node_attribute_xy from operator import itemgetter from networkx.exception import NetworkXError import networkx.convert as convert g = nx.read_edgelist('/home/suman/Desktop/dataset/Email-Enron.txt',create_using=None,nodetype=int,edgetype=int) s=sorted(g.degree_iter(),key= itemgetter(1),reverse=True) perc=1 def modify_nw_random(g,perc): while(perc&lt;=100): ntm = round((float(perc)/100)*len(g)) #print ntm while(ntm != 0): v = random.randrange(1,len(g)) print"node:", v d=g.degree(v) print"degree:", d g1=nx.Graph() g2=nx.Graph() if g.has_node(v) and (d&gt;=691): g1.add_node(v) else: g2.add_node(v) g.remove_node(v) ntm = ntm-1 if(ntm&lt;=0):break perc=perc+1 print "perc:",perc if(perc&gt;100):break N1=nx.number_of_nodes(g1) print N1 r2=nx.degree_assortativity_coefficient(g1) print ("%f"%r2) N2=nx.number_of_nodes(g2) print N2 r3=nx.degree_assortativity_coefficient(g2) print ("%f"%r3) modify_nw_random(g,perc) </code></pre> <p>here first loop are executed when perc = 1 and then perc is increase by 1 (perc=perc+1) this is not execute .it means following part of code is not participating in execution process</p> <pre><code>perc=perc+1 print "perc:",perc if(perc&gt;100):break print "node in g1:", g1.nodes() print "node in g2:", g2.nodes() N1=nx.number_of_nodes(g1) print N1 r2=nx.degree_assortativity_coefficient(g1) print ("%f"%r2) N2=nx.number_of_nodes(g2) print N2 r3=nx.degree_assortativity_coefficient(g2) print ("%f"%r3) </code></pre> <p>can any one help me that, for solving my mistakes in this code</p>