<?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 Re: Field Calculator with Python Code Block runs but returns null in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820508#M341</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just realized my problem.&amp;nbsp; Apparently some of the records in the table that I was calculating had null values.&amp;nbsp; This seems to be throwing off numerical functions.&amp;nbsp; I replace null with 0 values in the code and it is populating the field.&amp;nbsp; Thank you Dan and Joshua for taking a look&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Nov 2019 02:40:48 GMT</pubDate>
    <dc:creator>NealBanerjee</dc:creator>
    <dc:date>2019-11-12T02:40:48Z</dc:date>
    <item>
      <title>Field Calculator with Python Code Block runs but returns null</title>
      <link>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820504#M337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a Python expression that utilizes a code block that I am trying to run as a field calculation (manual or with Field Calculator geoprocessing tool).&amp;nbsp; The code runs without issue, but returns nulls even if I hard-code the return value to a simple string.&amp;nbsp; I have tried going through line by line to better understand where/why it is not working.&amp;nbsp; Best I can tell is it fails once I try to round a number.&amp;nbsp; The code does include some lists, dictionaries, and loops, but it works fine when I run in an independent Python IDE with hardcoded input values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the code snippet below, Ive hard coded the function just to return a "TEST" (see near bottom), but it return null.&amp;nbsp; If I take out the line with round statement it does at least return "TEST". I think Ive checked all my indentation, but cant think of anything else that may be causing the issue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does field calculator have any limitations with lists, loops, etc.?&amp;nbsp; Any ideas what may be causing this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts would be greatly appreciated!&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Neal&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-------------------- Code Snippet ---------&lt;/P&gt;&lt;P&gt;def Calc(ScrA, ScrB, ScrC, ScrD, ScrE, ScrF, ScrG, ScrH, ScrI, ScrJ, ScrK, ScrL, ScrM, multN, multO, multP, multQ, ScrTot):&lt;BR /&gt;&amp;nbsp; dicComMult={multN:"N", multO:"O", multP:"P",multQ:"Q"}&lt;BR /&gt;&amp;nbsp; maxMult = max(dicComMult)&lt;BR /&gt;&amp;nbsp; if maxMult &amp;gt; 1:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; maxMultCom = dicComMult[max(dicComMult)]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ScrMult = round(ScrTot - (ScrTot / maxMult),1)&lt;BR /&gt;&amp;nbsp; else:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; maxMultCom='NA'&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ScrMult = 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; lstCom = [("A", ScrA), ("B", ScrB), ("C", ScrC), ("D", ScrD), ("E", ScrE), ("F", ScrF), ("G", ScrG), ("H",ScrH), ("I", ScrI), ("J", ScrJ), ("K", ScrK), ("L", ScrL), ("M", ScrM), (maxMultCom,ScrMult)]&lt;BR /&gt;&amp;nbsp; lstHCFs=[]&lt;BR /&gt;&amp;nbsp; cumPctScr=0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for Com in lstCom:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; val=round(Com[1],1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; strlist=str(val)&lt;BR /&gt;&amp;nbsp; return "TEST"&lt;/P&gt;&lt;P&gt;------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Example Field Calculator that returns null" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/473059_test.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Nov 2019 21:41:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820504#M337</guid>
      <dc:creator>NealBanerjee</dc:creator>
      <dc:date>2019-11-11T21:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator with Python Code Block runs but returns null</title>
      <link>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820505#M338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Neal can you format it so alignment can be checked&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;not sure what that round section is doing and whether it is aligned&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Nov 2019 22:36:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820505#M338</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-11-11T22:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator with Python Code Block runs but returns null</title>
      <link>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820506#M339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree, the indentation can make a big difference, and in this case could easily explain why "TEST" isn't being returned.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Nov 2019 23:19:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820506#M339</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-11-11T23:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator with Python Code Block runs but returns null</title>
      <link>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820507#M340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Calc&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ScrA&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrB&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrC&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrD&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrE&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrF&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrG&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrH&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrI&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrJ&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrK&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrL&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrM&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multN&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multO&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multP&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multQ&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrTot&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
  dicComMult&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;multN&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"N"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multO&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"O"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multP&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"P"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;multQ&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Q"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
  maxMult &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dicComMult&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; maxMult &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    maxMultCom &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dicComMult&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dicComMult&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
    ScrMult &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; round&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ScrTot &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ScrTot &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; maxMult&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    maxMultCom&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'NA'&lt;/SPAN&gt;
    ScrMult &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;

  lstCom &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"A"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrA&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"B"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrB&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"C"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrC&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"D"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrD&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"E"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrE&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"F"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrF&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"G"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrG&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"H"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;ScrH&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"I"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrI&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"J"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrJ&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"K"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrK&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"L"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrL&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"M"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrM&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;maxMultCom&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;ScrMult&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
  lstHCFs&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
  cumPctScr&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; Com &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; lstCom&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
     PctScr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; round&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Com&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; ScrTot &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;100&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

  strlist&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;PctScr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TEST"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 22px;"&gt;The code &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;above&lt;/STRONG&gt;&lt;/SPAN&gt; returns "null" (not expected) when I run it&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966; font-size: 22px;"&gt;The code &lt;STRONG style="text-decoration: underline; "&gt;below&lt;/STRONG&gt; returns "TEST" (as expected) if I simply remove the round and division on line 15.&amp;nbsp; I did not change any indentation in the field calculator&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Calc&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ScrA&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrB&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrC&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrD&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrE&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrF&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrG&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrH&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrI&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrJ&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrK&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrL&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrM&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multN&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multO&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multP&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multQ&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrTot&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
  dicComMult&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;multN&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"N"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multO&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"O"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; multP&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"P"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;multQ&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Q"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
  maxMult &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dicComMult&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; maxMult &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    maxMultCom &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dicComMult&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dicComMult&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
    ScrMult &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; round&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ScrTot &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ScrTot &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; maxMult&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    maxMultCom&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'NA'&lt;/SPAN&gt;
    ScrMult &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;

  lstCom &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"A"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrA&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"B"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrB&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"C"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrC&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"D"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrD&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"E"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrE&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"F"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrF&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"G"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrG&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"H"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;ScrH&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"I"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrI&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"J"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrJ&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"K"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrK&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"L"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrL&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"M"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ScrM&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;maxMultCom&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;ScrMult&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
  lstHCFs&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
  cumPctScr&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; Com &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; lstCom&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
     PctScr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Com&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

  strlist&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;PctScr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TEST"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:43:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820507#M340</guid>
      <dc:creator>NealBanerjee</dc:creator>
      <dc:date>2021-12-12T09:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator with Python Code Block runs but returns null</title>
      <link>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820508#M341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just realized my problem.&amp;nbsp; Apparently some of the records in the table that I was calculating had null values.&amp;nbsp; This seems to be throwing off numerical functions.&amp;nbsp; I replace null with 0 values in the code and it is populating the field.&amp;nbsp; Thank you Dan and Joshua for taking a look&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2019 02:40:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/field-calculator-with-python-code-block-runs-but/m-p/820508#M341</guid>
      <dc:creator>NealBanerjee</dc:creator>
      <dc:date>2019-11-12T02:40:48Z</dc:date>
    </item>
  </channel>
</rss>

