I'd like to take this list and write it to a new txt file. Ignoring the ':' , {}, and words within quotation marks. so the txt file created would look like this:

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter10: Object-oriented Programming
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

shapes = [{'type': 'circle', 'x': 300, 'y': 300, 'radius': 100, 'color': 'cyan'},
{'type': 'circle', 'x': 300, 'y': 300, 'radius': 10, 'color': 'white'},
{'type': 'rectangle', 'x1': 500, 'y1': 500, 'x2': 550, 'y2': 580, 'color': 'green'},
{'type': 'line', 'x': 0, 'y': 0, 'a': 100, 'b': 300, 'color': "black", 'width': 7},
{'type': 'point', 'x': 200, 'y': 50, 'color': 'black'},
{'type': 'point', 'x': 205, 'y': 50, 'color': 'black'},
{'type': 'point', 'x': 210, 'y': 50, 'color': 'black'},
{'type': 'triangle', 'x': 500, 'y': 100, 'a': 600, 'b': 100, 'c': 550, 'd': 200, 'color': 'yellow'},
{'type': 'oval', 'x': 100, 'y': 100, 'a': 400, 'b': 400, 'color': 'red'},
{'type': 'text', 'x': 500, 'y': 50, 'message': 'hello world!', 'color': 'blue'}
]

I'd like to take this list and write it to a new txt file. Ignoring the ':' , {}, and words within quotation marks. so the txt file created would look like this: 


circle, 300,300, 100, cyan
circle, 300,300, 10, white
rectangle, 500,500, 550,580, green
line, 0,0, 100,300, black, 7
point, 200,50,black
point, 205,50,black
point, 210,50,black
triangle, 500,100, 600,100, 550,200, yellow
image, 150,500, cedar_rapids.ppm
oval, 100,100, 400,200, red
text, 500,50, hello world!, blue

what i have so far is:

s_shapes = ['{}\n'.format(i) for i in shapes]
textFileName = input("Save as: ")
with open(textFileName, "w") as fp:
fp.writelines(s_shapes)
fp.close()

it prints my list in the txt file, but doesnt get rid of the words in quotations, the :  or the {}. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning