I'm new to ArcPy and Python in general. I'm experimenting with Python within ArcGIS Pro, but I've encountered an issue, here is the code:
import arcpy
arcpy.env.workspace = "C:/Users/Nastgardaren/Desktop/Strangnas/Strangnas/Strangnas.gdb"
input_inkomst = arcpy.GetParameterAsText(0)
input_fastigheter = arcpy.GetParameterAsText(1)
inkomstklass = arcpy.GetParameterAsText(2)
klasstyp = arcpy.GetParameterAsText(3)
val_av_klass = arcpy.management.SelectLayerByAttribute(input_inkomst,'NEW_SELECTION',"'{}'='{}'".format(inkomstklass,klasstyp))
produkt = arcpy.management.SelectLayerByLocation(input_fastigheter, 'WITHIN', val_av_klass)
arcpy.CopyFeatures_management(produkt,'produkt2')
the idea with the project is to create a new layer, which represents polygons (a subset of the layer in input_fastigheter) within the containment of another vector layer (input_inkomst) based on values between 1-8 from a field in the input_inkomst layer (the layer is predetermined for the first parameter, but I made it a user defined parameter, just for the sake of the experiment). When I remove the fourth input parameter and assign a defined value between 1 and 8, then the script works fine, but when I run the script like I pasted here, then I get a empty layer as a result.
I have found a very similar question on this site: Get Parameter as Text and select layer by attribute
Although I tried to solve it the same way as the OP did, I wasn't succesful because the name of the field in the attribute table wasn't properly defined apparently according to the error i received. This lead me to create a fourth parameter in which the user writes the name of the field, but I'm still stuck on the issue of having an empty output.