'Python CSV double quotes between array

I am working on CSV files. How can I add double quotes between array?

    marketplaces = ['amazon', 'ebay', 'alibaba', 'walmart']
        with open('example.csv', 'a', encoding="utf-8") as f:
        # Writing data to a file
            writer = csv.writer(f, delimiter=",", quotechar='"', lineterminator="\n", quoting=csv.QUOTE_ALL)
            writer.writerow(marketplaces)

Print

"amazon","ebay","alibaba","walmart"

I want like this

"amazon,ebay,alibaba,walmart"


Solution 1:[1]

Done!

marketplaces = ['amazon', 'ebay', 'alibaba', 'walmart']
    with open('example.csv', 'a', encoding="utf-8") as f:
            # Writing data to a file
                f.write('"')
                for marketplace in marketplaces:
                    if marketplace != marketplaces[len(marketplaces)-1]:
                        f.write(marketplace + ",")
                    else:
                        f.write(marketplaces)
                f.write('"\n')

Output

"amazon,ebay,alibaba, walmart"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1