how do i convert this text into an array : "blink", "freakonomics", and "outliers" in python

To convert the given text into an array in Python, you can use the split() method and remove the quotes from the text. Here's an example:

main.py
text = '"blink", "freakonomics", and "outliers"'
# Remove the quotes from the text
text = text.replace('"', '')
# Split the text into an array
array = text.split(', ')

print(array)
182 chars
8 lines

Output:

main.py
['blink', 'freakonomics', 'and outliers']
42 chars
2 lines

In this code, we first remove the quotes from the text using the replace() method. Then, we split the text into an array using the split() method, with ', ' as the separator. Finally, we print the resulting array.

related categories

gistlibby LogSnag