<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to Sum a Listing of Counts in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-sum-a-listing-of-counts/m-p/622117#M48440</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm somewhat of a novice at Python but I created a script that performs a series of selections on some layers and then performs a count on each selection and displays the count in message window.&amp;nbsp; So far it's straight forward but I have two additionalcounts that require the summation of two other previous counts.&amp;nbsp; How do I achieve this summation of counts?&amp;nbsp; I've included my script below.&amp;nbsp; The last two line of the code are the ones in question that need to be summed.&amp;nbsp; Thank you for your help and advice, much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[PHP]import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Local variables:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_CLEARANCE = "ProductionGIS.GISADM.NCS_CLEARANCE"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_MILEPOST = "ProductionGIS.GISADM.NCS_MILEPOST"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_EQUATIONS = "ProductionGIS.GISADM.NCS_EQUATIONS"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_SIGN = "ProductionGIS.GISADM.NCS_SIGN"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_SIGNAL = "ProductionGIS.GISADM.NCS_SIGNAL"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_INTERLOCKING = "ProductionGIS.GISADM.NCS_INTERLOCKING"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_SWITCH = "ProductionGIS.GISADM.NCS_SWITCH"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_XING = "ProductionGIS.GISADM.NCS_XING"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events = "ProductionGIS.GISADM.NCS_SUB_CODE_EVT Events"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name = "ProductionGIS.GISADM.NCS_CLEARANCE"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__2_ = "ProductionGIS.GISADM.NCS_MILEPOST"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__3_ = "ProductionGIS.GISADM.NCS_EQUATIONS"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__4_ = "ProductionGIS.GISADM.NCS_SIGN"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__5_ = "ProductionGIS.GISADM.NCS_SIGNAL"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__6_ = "ProductionGIS.GISADM.NCS_INTERLOCKING"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__7_ = "ProductionGIS.GISADM.NCS_SWITCH"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__8_ = "ProductionGIS.GISADM.NCS_XING"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_CLEARANCE, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_MILEPOST, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_EQUATIONS, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_SIGN, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_SIGNAL, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (6)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_INTERLOCKING, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (7)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_SWITCH, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (8)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_XING, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result1 = arcpy.GetCount_management(Output_Layer_Name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount1 = int(result1.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result2 = arcpy.GetCount_management(Output_Layer_Name__2_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount2 = int(result2.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result3 = arcpy.GetCount_management(Output_Layer_Name__3_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount3 = int(result3.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result4 = arcpy.GetCount_management(Output_Layer_Name__4_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount4 = int(result4.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result5 = arcpy.GetCount_management(Output_Layer_Name__5_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount5 = int(result5.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result6 = arcpy.GetCount_management(Output_Layer_Name__6_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount6 = int(result6.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result7 = arcpy.GetCount_management(Output_Layer_Name__7_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount7 = int(result7.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result8 = arcpy.GetCount_management(Output_Layer_Name__8_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount8 = int(result8.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Clearance Point Count = " + str(featurecount1))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Milepost Point Count = " + str(featurecount2))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Equations Point Count = " + str(featurecount3))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Sign Point Count = " + str(featurecount4))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Signal Point Count = " + str(featurecount5))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Interlocking Point Count = " + str(featurecount6))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Switch Point Count = " + str(featurecount7))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Xing Point Count = " + str(featurecount8))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Nodes Point Count = " + str(featurecount3)+str(featurecount7))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Milepost Helper Point Count = " + (str(featurecount3)+str(featurecount7)+str(featurecount5)+str(featurecount2)))[/PHP]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Jun 2012 18:14:10 GMT</pubDate>
    <dc:creator>JakobHowe</dc:creator>
    <dc:date>2012-06-27T18:14:10Z</dc:date>
    <item>
      <title>How to Sum a Listing of Counts</title>
      <link>https://community.esri.com/t5/python-questions/how-to-sum-a-listing-of-counts/m-p/622117#M48440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm somewhat of a novice at Python but I created a script that performs a series of selections on some layers and then performs a count on each selection and displays the count in message window.&amp;nbsp; So far it's straight forward but I have two additionalcounts that require the summation of two other previous counts.&amp;nbsp; How do I achieve this summation of counts?&amp;nbsp; I've included my script below.&amp;nbsp; The last two line of the code are the ones in question that need to be summed.&amp;nbsp; Thank you for your help and advice, much appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[PHP]import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Local variables:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_CLEARANCE = "ProductionGIS.GISADM.NCS_CLEARANCE"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_MILEPOST = "ProductionGIS.GISADM.NCS_MILEPOST"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_EQUATIONS = "ProductionGIS.GISADM.NCS_EQUATIONS"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_SIGN = "ProductionGIS.GISADM.NCS_SIGN"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_SIGNAL = "ProductionGIS.GISADM.NCS_SIGNAL"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_INTERLOCKING = "ProductionGIS.GISADM.NCS_INTERLOCKING"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_SWITCH = "ProductionGIS.GISADM.NCS_SWITCH"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_XING = "ProductionGIS.GISADM.NCS_XING"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events = "ProductionGIS.GISADM.NCS_SUB_CODE_EVT Events"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name = "ProductionGIS.GISADM.NCS_CLEARANCE"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__2_ = "ProductionGIS.GISADM.NCS_MILEPOST"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__3_ = "ProductionGIS.GISADM.NCS_EQUATIONS"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__4_ = "ProductionGIS.GISADM.NCS_SIGN"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__5_ = "ProductionGIS.GISADM.NCS_SIGNAL"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__6_ = "ProductionGIS.GISADM.NCS_INTERLOCKING"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__7_ = "ProductionGIS.GISADM.NCS_SWITCH"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Layer_Name__8_ = "ProductionGIS.GISADM.NCS_XING"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_CLEARANCE, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_MILEPOST, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_EQUATIONS, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_SIGN, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_SIGNAL, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (6)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_INTERLOCKING, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (7)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_SWITCH, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Select Layer By Location (8)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management(ProductionGIS_GISADM_NCS_XING, "INTERSECT", ProductionGIS_GISADM_NCS_SUB_CODE_EVT_Events, "", "NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result1 = arcpy.GetCount_management(Output_Layer_Name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount1 = int(result1.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result2 = arcpy.GetCount_management(Output_Layer_Name__2_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount2 = int(result2.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result3 = arcpy.GetCount_management(Output_Layer_Name__3_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount3 = int(result3.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result4 = arcpy.GetCount_management(Output_Layer_Name__4_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount4 = int(result4.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result5 = arcpy.GetCount_management(Output_Layer_Name__5_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount5 = int(result5.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result6 = arcpy.GetCount_management(Output_Layer_Name__6_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount6 = int(result6.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result7 = arcpy.GetCount_management(Output_Layer_Name__7_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount7 = int(result7.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result8 = arcpy.GetCount_management(Output_Layer_Name__8_)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;featurecount8 = int(result8.getOutput(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Clearance Point Count = " + str(featurecount1))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Milepost Point Count = " + str(featurecount2))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Equations Point Count = " + str(featurecount3))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Sign Point Count = " + str(featurecount4))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Signal Point Count = " + str(featurecount5))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Interlocking Point Count = " + str(featurecount6))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Switch Point Count = " + str(featurecount7))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Xing Point Count = " + str(featurecount8))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Nodes Point Count = " + str(featurecount3)+str(featurecount7))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Milepost Helper Point Count = " + (str(featurecount3)+str(featurecount7)+str(featurecount5)+str(featurecount2)))[/PHP]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jun 2012 18:14:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-sum-a-listing-of-counts/m-p/622117#M48440</guid>
      <dc:creator>JakobHowe</dc:creator>
      <dc:date>2012-06-27T18:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sum a Listing of Counts</title>
      <link>https://community.esri.com/t5/python-questions/how-to-sum-a-listing-of-counts/m-p/622118#M48441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would sum like this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.AddMessage("Milepost Helper Point Count = {0}".format(featurecount3+featurecount7+featurecount5+featurecount2))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jun 2012 18:26:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-sum-a-listing-of-counts/m-p/622118#M48441</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-06-27T18:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sum a Listing of Counts</title>
      <link>https://community.esri.com/t5/python-questions/how-to-sum-a-listing-of-counts/m-p/622119#M48442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This works just as you said, thank you so much for the quick reply. Regards.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jun 2012 18:46:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-sum-a-listing-of-counts/m-p/622119#M48442</guid>
      <dc:creator>JakobHowe</dc:creator>
      <dc:date>2012-06-27T18:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Sum a Listing of Counts</title>
      <link>https://community.esri.com/t5/python-questions/how-to-sum-a-listing-of-counts/m-p/622120#M48443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This works just as you said, thank you so much for the quick reply. Regards.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;No problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And if you want something a little prettier, you can do something like this. Untested and not really optimal, but a step in the pythonic direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

# Local variables:
events = "ProductionGIS.GISADM.NCS_SUB_CODE_EVT Events"

layer_list = ["ProductionGIS.GISADM.NCS_CLEARANCE",
"ProductionGIS.GISADM.NCS_MILEPOST",
"ProductionGIS.GISADM.NCS_EQUATIONS",
"ProductionGIS.GISADM.NCS_SIGN",
"ProductionGIS.GISADM.NCS_SIGNAL",
"ProductionGIS.GISADM.NCS_INTERLOCKING",
"ProductionGIS.GISADM.NCS_SWITCH",
"ProductionGIS.GISADM.NCS_XING"
]

result_list = []
nodes_list = ["Equations","Switch"]
milepost_additions = ["Milepost","Signal"]
node_count = 0
milepost_count = 0

for layer in layer_list:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(layer, "INTERSECT", events, "", "NEW_SELECTION")
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = arcpy.GetCount_management(layer)
&amp;nbsp;&amp;nbsp;&amp;nbsp; result_list.append([layer.split("_")[-1],int(result.getOutput(0))])

for name,count in result_list:
&amp;nbsp;&amp;nbsp;&amp;nbsp; name = name.capitalize()
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("{0} Point Count = {1}".format(name,count))
&amp;nbsp;&amp;nbsp;&amp;nbsp; if name in nodes_list:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; node_count += count
&amp;nbsp;&amp;nbsp;&amp;nbsp; if name in milepost_additions:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; milepost_count += count

arcpy.AddMessage("Nodes Point Count = {0}".format(node_count))
arcpy.AddMessage("Milepost Helper Point Count = {0}".format(node_count+milepost_count))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:31:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-sum-a-listing-of-counts/m-p/622120#M48443</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T02:31:12Z</dc:date>
    </item>
  </channel>
</rss>

