Skip to content
Advertisement

How to convert string data having comma to a list in python

I have a string as below:

JavaScript

I want to convert this string into a list, but when I try to do this using .split(",") I am getting an list as below:

JavaScript

I would like to have a list as:

JavaScript

How can I achieve this?

Advertisement

Answer

The initial list has " missing in first word.

We can use ast module in this case –

JavaScript

Other alternative would be to make use of json module

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement