-3

New to python and I keep running into this error

HELP PLEASE THE CODE IS HERE

Runtime error Traceback (most recent call last): File "", line 5, in TypeError: cannot concatenate 'str' and 'int' objects

  • 1
    Just change "OBJECTID = " + row[0] into "OBJECTID = " + str(row[0]) – Kadir Şahbaz May 23 '18 at 20:24
  • 2
    Please don't use screenshots to show code and exceptions. Copy and paste it in as text, then highlight/select it and use the {} button to format as code. – user2856 May 23 '18 at 21:38
1

your value in row[0] is an integer, but you are trying to combine (concatenate) it with a string (text). You can fix this by temporarily casting row[0] as a string using the built in str() method.

Try this:

arcpy.MakeFeatureLayer_mangement(Fitting, "fcLyr", "OBJECTID = "+ str(row[0]))

Or you could use the format method to insert the integer directly into the query string:

arcpy.MakeFeatureLayer_management(Fitting, "fcLyr", "OBJECTID = {}".format(row[0]))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.