<?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: Python. Simple script not working. Synthax error!! in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-simple-script-not-working-synthax-error/m-p/305168#M23699</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jen,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You're close. What is going wrong in your script is that in the definition of the&amp;nbsp; function you provide your field name, which contains a dot. What you&amp;nbsp; should provide is the name (any name) for a variable. In my example I&amp;nbsp; use "building_height" and "store_height". &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As pre-logic script code you can use this (this includes logic for buildings that have more than 2 stories and being able to define the storey height):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def getStories(building_height, store_height):
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "{0} storey".format(int(building_height / store_height) + 1)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The function is called like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;getStories( !YourFieldName!, 4)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please not that in this code 4 height units will return "1 storey", but 4.1 height units, will return "2 storey". I don't know if that is entirely correct...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:36:50 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-12-11T14:36:50Z</dc:date>
    <item>
      <title>Python. Simple script not working. Synthax error!!</title>
      <link>https://community.esri.com/t5/python-questions/python-simple-script-not-working-synthax-error/m-p/305167#M23698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am looking to redefine the average height attribute as either 1 or 2 story depending on their height. Any height less than 4 = 1 storey house and height above 4 = 2 storey house.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please see screenshot of script. Have not used python much before and any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks[ATTACH=CONFIG]31973[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Mar 2014 07:52:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-simple-script-not-working-synthax-error/m-p/305167#M23698</guid>
      <dc:creator>jenkelly</dc:creator>
      <dc:date>2014-03-06T07:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python. Simple script not working. Synthax error!!</title>
      <link>https://community.esri.com/t5/python-questions/python-simple-script-not-working-synthax-error/m-p/305168#M23699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jen,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You're close. What is going wrong in your script is that in the definition of the&amp;nbsp; function you provide your field name, which contains a dot. What you&amp;nbsp; should provide is the name (any name) for a variable. In my example I&amp;nbsp; use "building_height" and "store_height". &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As pre-logic script code you can use this (this includes logic for buildings that have more than 2 stories and being able to define the storey height):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def getStories(building_height, store_height):
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "{0} storey".format(int(building_height / store_height) + 1)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The function is called like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;getStories( !YourFieldName!, 4)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please not that in this code 4 height units will return "1 storey", but 4.1 height units, will return "2 storey". I don't know if that is entirely correct...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:36:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-simple-script-not-working-synthax-error/m-p/305168#M23699</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T14:36:50Z</dc:date>
    </item>
  </channel>
</rss>

