<?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 UpdateCursor issue: &amp;amp;amp;quot;can't multiply sequence by non-int of type 'float' in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/updatecursor-issue-amp-amp-quot-can-t-multiply/m-p/691959#M53647</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Attempting to use an update cursor to update a field 'Cost' by multiplying the value in the field 'Area' by a value input by the user.&amp;nbsp; The trouble seems to be getting the variables "Price1" and "Price2" to work inside the cursor's If statements.&amp;nbsp; If I simply replace the variable with a number, such as 2, then the script works fine, but it really needs to multiply a variable that the user has entered.&amp;nbsp; The variable that the user enters will be a money value, so it's of type Double with 2 decimal places.&amp;nbsp; The error I get is "can't multiply sequence by non-int of type 'float'".&amp;nbsp; Here's a snippet of the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Price1 = arcpy.GetParameterAsText(0) Price2 = arcpy.GetParameterAsText(1)&amp;nbsp; fcName = "My_lyr" fields = ['Area','Description','Cost']&amp;nbsp; #Note that 'Area' is type DOUBLE, 'Description' is TEXT, and 'Cost' is DOUBLE&amp;nbsp; CostCursor = arcpy.da.UpdateCursor(fcName,fields)&amp;nbsp; for row in CostCursor:&amp;nbsp; if row[1] == "Category 1": &amp;nbsp; row[2] = (row[0] * Price1)&amp;nbsp; elif row[1] == "Category 2": &amp;nbsp; row[2] = (row[0] * Price2)&amp;nbsp; else: &amp;nbsp; row [2] = 0&amp;nbsp; CostCursor.updateRow(row)&amp;nbsp; del row del CostCursor&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 16 Nov 2013 00:33:51 GMT</pubDate>
    <dc:creator>DamonOsbourne</dc:creator>
    <dc:date>2013-11-16T00:33:51Z</dc:date>
    <item>
      <title>UpdateCursor issue: &amp;amp;quot;can't multiply sequence by non-int of type 'float'</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-issue-amp-amp-quot-can-t-multiply/m-p/691959#M53647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Attempting to use an update cursor to update a field 'Cost' by multiplying the value in the field 'Area' by a value input by the user.&amp;nbsp; The trouble seems to be getting the variables "Price1" and "Price2" to work inside the cursor's If statements.&amp;nbsp; If I simply replace the variable with a number, such as 2, then the script works fine, but it really needs to multiply a variable that the user has entered.&amp;nbsp; The variable that the user enters will be a money value, so it's of type Double with 2 decimal places.&amp;nbsp; The error I get is "can't multiply sequence by non-int of type 'float'".&amp;nbsp; Here's a snippet of the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Price1 = arcpy.GetParameterAsText(0) Price2 = arcpy.GetParameterAsText(1)&amp;nbsp; fcName = "My_lyr" fields = ['Area','Description','Cost']&amp;nbsp; #Note that 'Area' is type DOUBLE, 'Description' is TEXT, and 'Cost' is DOUBLE&amp;nbsp; CostCursor = arcpy.da.UpdateCursor(fcName,fields)&amp;nbsp; for row in CostCursor:&amp;nbsp; if row[1] == "Category 1": &amp;nbsp; row[2] = (row[0] * Price1)&amp;nbsp; elif row[1] == "Category 2": &amp;nbsp; row[2] = (row[0] * Price2)&amp;nbsp; else: &amp;nbsp; row [2] = 0&amp;nbsp; CostCursor.updateRow(row)&amp;nbsp; del row del CostCursor&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2013 00:33:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-issue-amp-amp-quot-can-t-multiply/m-p/691959#M53647</guid>
      <dc:creator>DamonOsbourne</dc:creator>
      <dc:date>2013-11-16T00:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor issue: "can't multiply sequence by non-int of type 'float'</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-issue-amp-amp-quot-can-t-multiply/m-p/691960#M53648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Attempting to use an update cursor to update a field 'Cost' by multiplying the value in the field 'Area' by a value input by the user.&amp;nbsp; The trouble seems to be getting the variables "Price1" and "Price2" to work inside the cursor's If statements.&amp;nbsp; If I simply replace the variable with a number, such as 2, then the script works fine, but it really needs to multiply a variable that the user has entered.&amp;nbsp; The variable that the user enters will be a money value, so it's of type Double with 2 decimal places.&amp;nbsp; The error I get is "can't multiply sequence by non-int of type 'float'".&amp;nbsp; Here's a snippet of the code:&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Price1 = float(arcpy.GetParameterAsText(0)) Price2 = float(arcpy.GetParameterAsText(1))&amp;nbsp; fcName = "My_lyr" fields = ['Area','Description','Cost']&amp;nbsp; #Note that 'Area' is type DOUBLE, 'Description' is TEXT, and 'Cost' is DOUBLE&amp;nbsp; CostCursor = arcpy.da.UpdateCursor(fcName,fields)&amp;nbsp; for row in CostCursor:&amp;nbsp; if row[1] == "Category 1": &amp;nbsp; row[2] = (row[0] * Price1)&amp;nbsp; elif row[1] == "Category 2": &amp;nbsp; row[2] = (row[0] * Price2)&amp;nbsp; else: &amp;nbsp; row [2] = 0&amp;nbsp; CostCursor.updateRow(row)&amp;nbsp; del row del CostCursor&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The parameters created by the GetParameterAsText method are always type string and have to be explicitly converted to a float before using them in numeric calculations.&amp;nbsp; Just change the parameter variable assignment code to this: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Price1 = float(arcpy.GetParameterAsText(0))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Price2 = float(arcpy.GetParameterAsText(1))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code assumes the script tool input types are set up to be required fields that only allow type double values to be entered to avoid having to do the parameter assignment and type validation checks in the code.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2013 06:07:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-issue-amp-amp-quot-can-t-multiply/m-p/691960#M53648</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-11-16T06:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor issue: "can't multiply sequence by non-int of type 'float'</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-issue-amp-amp-quot-can-t-multiply/m-p/691961#M53649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, that was it.&amp;nbsp; Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2013 13:27:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-issue-amp-amp-quot-can-t-multiply/m-p/691961#M53649</guid>
      <dc:creator>DamonOsbourne</dc:creator>
      <dc:date>2013-11-16T13:27:51Z</dc:date>
    </item>
  </channel>
</rss>

