I have a list with mixed object types (strings and ints), and what I want to do is .join that list into a string where each string is wrapped in quotes BESIDES the integers. So for example if I had this list:
sample_list = ['abcd', 'chicken', 'wasd', 1, 'blah', 3, 'foo', 'bar']
I would like to produce the following string from it:
sample_string = "('abcd', 'chicken', 'wasd', 1, 'blah', 3, 'foo', 'bar')"
This is what I have:
sample_string = "(" + ', '.join("'{0}'".format(item) for item in sample_list if type(item) is not int) + ")"
Clearly my code is wrong because my integer values end up being dropped due to the 'if' statement, but I've gotten stuck figuring out an elegant way to produce the string I desire, and was wondering if anyone could help with providing some tips on how to do so.
Thanks in advance!