i have a list in python that looks like this ['a','b','c'] and i want it to look like ["a","b","c"]. I tried using some replace functions and looping the list and adding '"' before and after the element but its not working.
I receive the list from the import block in terraform as dictionary and also the replace function is not working there. I need it to look like this ["a","b","c"] because i want to generate another terraform file that will use that list for a variable but using ' in terraform for strings is not working.
How can i solve this?
>Solution :
Sounds like you want to dump a list in json format.
Python has a module in its standard library for it.
import json
l = ['a', 'b']
print(l)
l_str = json.dumps(l)
print(l_str)