Skip to main content

youYou have one level of quote too much. If your variable is already a string, no need to add extra "" to tell that it is a string. You should thinkThink of what you want to write if you run a selection in ArcMap. In this case:

Att=Att = 'Red'

while your where_clause gives:

"Att = 'Red'"

In youyour case, you should use this where clause:

where_clause = "Att = '{}'".format(val)

or

where_clause = "Att = '"+'" val++ val + "'"

you have one level of quote too much. If your variable is already a string, no need to add extra "" to tell that it is a string. You should think of what you write if you run a selection in ArcMap

Att= 'Red'

while your where_clause gives

"Att = 'Red'"

In you case, you should use this where clause

where_clause = "Att = '{}'".format(val)

or

where_clause = "Att = '"+ val+ "'"

You have one level of quote too much. If your variable is already a string, no need to add extra "" to tell that it is a string. Think of what you want to write if you run a selection in ArcMap. In this case:

Att = 'Red'

while your where_clause gives:

"Att = 'Red'"

In your case, you should use this where clause:

where_clause = "Att = '{}'".format(val)

or

where_clause = "Att = '" + val + "'"
added 1 character in body
Source Link
radouxju
  • 49.9k
  • 2
  • 71
  • 144

you have one level of quote too much. If your variable is already a string, no need to add extra "" to tell that it is a string. You should think of what you write if you run a selection in ArcMap

Att= 'Red'

while your where_clause gives

"Att = 'Red'"

"Att = 'Red'"

In you case, you should use this where clause

where_clause = "Att = '{}'".format(val)

or

where_clause = "Att = '"+ val+ "'"

you have one level of quote too much. If your variable is already a string, no need to add extra "" to tell that it is a string. You should think of what you write if you run a selection in ArcMap

Att= 'Red'

while your where_clause gives

"Att = 'Red'"

In you case, you should use this where clause

where_clause = "Att = '{}'".format(val)

or

where_clause = "Att = '"+ val+ "'"

you have one level of quote too much. If your variable is already a string, no need to add extra "" to tell that it is a string. You should think of what you write if you run a selection in ArcMap

Att= 'Red'

while your where_clause gives

"Att = 'Red'"

In you case, you should use this where clause

where_clause = "Att = '{}'".format(val)

or

where_clause = "Att = '"+ val+ "'"
Source Link
radouxju
  • 49.9k
  • 2
  • 71
  • 144

you have one level of quote too much. If your variable is already a string, no need to add extra "" to tell that it is a string. You should think of what you write if you run a selection in ArcMap

Att= 'Red'

while your where_clause gives

"Att = 'Red'"

In you case, you should use this where clause

where_clause = "Att = '{}'".format(val)

or

where_clause = "Att = '"+ val+ "'"