Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

python array to string but with commas on every string return

I have a array something like this

my_array = ['MY_INVOICE', 'YOUR_INVOICE']

and when I convert it to a string using like this

final_string +=  ','.join(my_array)

it is giving something like this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

MY_INVOICE,YOUR_INVOICE

while I want something like this

"MY_INVOICE", "YOUR_INVOICE" (like with commas on it) tried few solutions but not working

>Solution :

Here’s what I think you’re looking for.

my_array = ['MY_INVOICE', 'YOUR_INVOICE']
print('"' + '", "'.join(my_array) + '"')

Result:

"MY_INVOICE", "YOUR_INVOICE"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading