title: To input a file and get a formatted string output using .format()
body: <p>Write a function named <code>calculate_expenses</code> that receives a filename as argument. The file contains the information about a person's expenses on items. Your function should return a list of tuples sorted based on the name of the items. Each tuple consists of the name of the item and total expense of that item as shown below:</p>
  
  <p><img src="https://i.stack.imgur.com/xJ7Y3.png" alt="enter image description here"></p>
  
  <p>Notice that each line of the file only includes an item and the purchase price of that item separated by a comma. There may be spaces before or after the item or the price. Then your function should read the file and return a list of tuples such as:</p>
  
  <p><img src="https://i.stack.imgur.com/knbuY.png" alt="enter image description here"></p>
  
  <p>Notes:</p>
  
  <ul>
  <li><p>Tuples are sorted based on the item names i.e. bread comes before chips which comes before milk.</p></li>
  <li><p>The total expenses are strings which start with a $ and they have two digits of accuracy after the decimal point.</p></li>
  </ul>
  
  <p>Hint: Use <code>${:.2f}</code> to properly create and format strings for the total expenses.</p>
  
  <p>The code so far:</p>
  
  <pre><code>def calculate_expenses(file_name):
  file_pointer = open(file_name, 'r')
  data = file_pointer.readlines()
  list_main=[]
  for line in data:
      name, price = line.strip().split(',')
      print (name, price)
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>('milk', '2.35')
  ('bread ', ' 1.95')
  ('chips ', '    2.54')
  ('milk  ', '    2.38')
  ('milk', '2.31')
  ('bread', '    1.90')
  </code></pre>
  
  <p>I can't get rid of the spaces and don't know what to do next.</p>