CSV and JSON files · 6 / 15 Exercise Easy

Column total

Objective

Create a Python program that reads lines in CSV format and adds up one of their columns with the csv module.

Instructions

  • Read an integer n and then n lines with the format product,price.
  • Go through the lines with csv.reader (you can pass it the list of lines directly).
  • Add up the prices, which are in the second column.
  • Show Total: T, with the total to two decimals.
Input
3
pan,1.20
leche,0.95
huevos,2.35
Output
Total: 4.50

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise