AnsweredAssumed Answered

How to add quotes around items in a List.

Question asked by deleted-user-yC5VkbyXzrQR on Jul 21, 2019
Latest reply on Jul 25, 2019 by bixb0012

How do I put quotes around the items in the variable ? 

b = ['23','25']
a = ['003','030']

sql = "{} IN ({}) AND {} IN ({})".format("STATE_CODE",", ".join([str(m) for m in b]), "CNTY_CODE", ", ".join([str(n) for n in a]))


It will spit out something like this


 'STATE_CODE IN (23, 25) AND CNTY_CODE IN (003, 030)'


I need the quotes around the numbers. mapping.DefintionQuery does not like the zeros for some reason. I believe its because there's no quotes around the number.


So I need it to look like below. 


SQL = "STATE_CODE IN ('23', '25') AND CNTY_CODE IN ('003', '030')"