<?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 Python doesn't work in field calculator in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-doesn-t-work-in-field-calculator/m-p/1128868#M63342</link>
    <description>&lt;P&gt;Merry Christmas to everyone,&lt;/P&gt;&lt;P&gt;I'm trying this code in field calculator tool but something is wrong with python. It seems that doesn't validate the code, doesn't recognize the len and replace function as reserved words. And, when I tries to execute the tool it shows an error "2 parameters are missing or invalid".&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RicardoSanabria1_0-1640558151880.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/30358iFB875B7943779BAD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RicardoSanabria1_0-1640558151880.png" alt="RicardoSanabria1_0-1640558151880.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried restarting the laptop, but it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
    <pubDate>Sun, 26 Dec 2021 22:36:25 GMT</pubDate>
    <dc:creator>RicardoSanabria1</dc:creator>
    <dc:date>2021-12-26T22:36:25Z</dc:date>
    <item>
      <title>Python doesn't work in field calculator</title>
      <link>https://community.esri.com/t5/python-questions/python-doesn-t-work-in-field-calculator/m-p/1128868#M63342</link>
      <description>&lt;P&gt;Merry Christmas to everyone,&lt;/P&gt;&lt;P&gt;I'm trying this code in field calculator tool but something is wrong with python. It seems that doesn't validate the code, doesn't recognize the len and replace function as reserved words. And, when I tries to execute the tool it shows an error "2 parameters are missing or invalid".&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RicardoSanabria1_0-1640558151880.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/30358iFB875B7943779BAD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RicardoSanabria1_0-1640558151880.png" alt="RicardoSanabria1_0-1640558151880.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried restarting the laptop, but it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Sun, 26 Dec 2021 22:36:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-doesn-t-work-in-field-calculator/m-p/1128868#M63342</guid>
      <dc:creator>RicardoSanabria1</dc:creator>
      <dc:date>2021-12-26T22:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python doesn't work in field calculator</title>
      <link>https://community.esri.com/t5/python-questions/python-doesn-t-work-in-field-calculator/m-p/1128870#M63344</link>
      <description>&lt;P&gt;your code block has to be a "def" as in the help topics&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/modelbuilder-toolbox/examples-of-using-calculate-value-tool.htm" target="_blank"&gt;Examples of using Calculate Value—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;modify the example to suit&lt;/P&gt;&lt;LI-CODE lang="python"&gt;txt = "a, b, c, d"

def func(val):
    """replace"""
    return len(val) - len(val.replace(",", ""))
    

func(txt)
3&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Dec 2021 23:00:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-doesn-t-work-in-field-calculator/m-p/1128870#M63344</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-12-26T23:00:03Z</dc:date>
    </item>
  </channel>
</rss>

