Loading...
Loading...
Loading...
A JSON list of objects with the keys id and item arrives on one line. Print it as CSV: first the header id,item, then one line per object. Use the csv module so that a comma in an item is quoted.
id and item.Example
Input
[{"id":1,"item":"Pen"},{"id":2,"item":"Book"}]Output
id,item 1,Pen 2,Book
A header and two rows.
Try the problem first. Open one hint at a time.
csv.writer(sys.stdout, lineterminator="\n") writes to the screen with plain newlines.
Write the header with writerow, then each object as a list of its values.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor