Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Read the contents of the text file and store it in a variable.
  2. Convert the string data into a Python list using the ast.literal_eval() method.
  3. Convert the list into a JSON format using the json.dumps() method.
  4. Write the JSON data to a new file or overwrite the existing one if desired.