<?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: Need Help with Python Syntax in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714809#M55470</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Won't the above code result in an empty string, every time?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead:&lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FedRoute(tvalue, shield):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if tvalue == 'INT':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return str(shield)
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif tvalue == 'US':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return str(shield)

FedRoute(!HWY_Type!, !SHIELD_VAL!)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 06:36:27 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2021-12-12T06:36:27Z</dc:date>
    <item>
      <title>Need Help with Python Syntax</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714807#M55468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello folks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need help with the proper syntax. I'm sure it's easy I just cant get it.&amp;nbsp; Basically it's telling me that the syntax for my return value, Str(!SHIELD_VAL!), is invalid.&amp;nbsp; I'm using a field calculator to run a check on field &lt;/SPAN&gt;&lt;STRONG&gt;HWY_Type&lt;/STRONG&gt;&lt;SPAN&gt; and given certain values, it will populate field &lt;/SPAN&gt;&lt;STRONG&gt;FEDROUTE&lt;/STRONG&gt;&lt;SPAN&gt; with the value of &lt;/SPAN&gt;&lt;STRONG&gt;SHIELD_VAL&lt;/STRONG&gt;&lt;SPAN&gt;.&amp;nbsp; Any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Alan&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def FedRoute(tvalue): &amp;nbsp;&amp;nbsp;&amp;nbsp; value = tvalue &amp;nbsp;&amp;nbsp;&amp;nbsp; if value == 'INT': &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Str(!SHIELD_VAL!) &amp;nbsp;&amp;nbsp;&amp;nbsp; elif value == 'US': &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Str(!SHIELD_VAL!)&amp;nbsp; FedRoute(!HWY_Type!)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 11:47:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714807#M55468</guid>
      <dc:creator>AlanToms</dc:creator>
      <dc:date>2012-02-24T11:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Python Syntax</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714808#M55469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alan, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You need to include the SHIELD_VAL field as an input variable in order to read the values.&amp;nbsp; The code below should fix your problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FedRoute(tvalue, shield):
&amp;nbsp;&amp;nbsp;&amp;nbsp; value = tvalue
&amp;nbsp;&amp;nbsp;&amp;nbsp; shield = ''
&amp;nbsp;&amp;nbsp;&amp;nbsp; if value == 5:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shield = str(shield)
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif value == 9:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shield =&amp;nbsp; str(shield)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return shield

FedRoute(!HWY_Type!, !SHIELD_VAL!)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:36:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714808#M55469</guid>
      <dc:creator>LeonardWilliamson</dc:creator>
      <dc:date>2021-12-12T06:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Python Syntax</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714809#M55470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Won't the above code result in an empty string, every time?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead:&lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FedRoute(tvalue, shield):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if tvalue == 'INT':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return str(shield)
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif tvalue == 'US':
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return str(shield)

FedRoute(!HWY_Type!, !SHIELD_VAL!)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:36:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714809#M55470</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-12T06:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Python Syntax</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714810#M55471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oops, I was testing the code and forgot to change the values to the original&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 14:13:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714810#M55471</guid>
      <dc:creator>LeonardWilliamson</dc:creator>
      <dc:date>2012-02-24T14:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Python Syntax</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714811#M55472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried both examples (Leonard's modified to my data, Darrens' exaclty)&amp;nbsp; and they both returned the following error.&amp;nbsp; I looked up 'exceptions.SyntaxError' but I do not understand this enough to solve the issue.&amp;nbsp; Any other suggestions?&amp;nbsp; Thanks for the help on this. It is appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Error running expression: FedRoute("INT", "75&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;") &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: EOL while scanning string literal (&amp;lt;string&amp;gt;, line 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Calculate Field (FEDROUTE)).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 17:20:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714811#M55472</guid>
      <dc:creator>AlanToms</dc:creator>
      <dc:date>2012-02-24T17:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Python Syntax</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714812#M55473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Did you choose Python as the parser?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 17:33:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714812#M55473</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2012-02-24T17:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Python Syntax</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714813#M55474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I choose Python 9.3&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 17:57:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714813#M55474</guid>
      <dc:creator>AlanToms</dc:creator>
      <dc:date>2012-02-24T17:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Python Syntax</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714814#M55475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are "Int" and "US" the only values?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 19:07:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714814#M55475</guid>
      <dc:creator>LeonardWilliamson</dc:creator>
      <dc:date>2012-02-24T19:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Python Syntax</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714815#M55476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yeah I seem to have NULL values in both the HWY_Type and SHIELD_VAL fields that I think is causing the problem.&amp;nbsp; I'll take a look at it again on Monday.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2012 20:18:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714815#M55476</guid>
      <dc:creator>AlanToms</dc:creator>
      <dc:date>2012-02-24T20:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Python Syntax</title>
      <link>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714816#M55477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The code samples you both provided worked.&amp;nbsp; I discovered some issues with the data iteself that didnt want to work.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for the help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Alan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Feb 2012 18:05:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-help-with-python-syntax/m-p/714816#M55477</guid>
      <dc:creator>AlanToms</dc:creator>
      <dc:date>2012-02-29T18:05:11Z</dc:date>
    </item>
  </channel>
</rss>

