title: How do I calculate the total sum of my cart to my dictionary list based on user input menu?
body: <p>I have created a simple menu to add things based on user input.</p>
  <pre><code>dictionary = {&quot;Service A&quot;: 100, &quot;Service B&quot;: 200}
  cart = []
  
  def main():
      while(True):
          print(&quot;1. List of Services&quot;)
          print(&quot;2. Payment&quot;)
          print(&quot;3. Exit&quot;)
          print(&quot;\nServices you have added:&quot;, cart)
  
          a = input(&quot;Please enter a choice: &quot;)
          if a==&quot;1&quot;:
              Q1()
          elif a==&quot;2&quot;:
              Q2()            
          elif a==&quot;3&quot;:
              break
  
  def Q1():
      print('1. Service A  :            $100/year')
      print('2. Service B  :            $200/year\n')
      service = input(&quot;Enter the service 1-2 that you would like to add: &quot;)
      
      if not service.isnumeric():
          print('Please enter valid choice number!')
  
      elif service.isnumeric():
          print(f'\nYou have selected choice number {service} which is: ')
  
          if service == '1':            
              print ('\n''1. Service A: $100/year.''\n')
              cart.append (&quot;Service A&quot;)
  
          if service == '2':
              print ('\n''2. Service B: $200/year.''\n')
              print('You will be return to main menu.')
              cart.append (&quot;Service B&quot;)
  
  def Q2():
      print(&quot;\nServices you have added:&quot;, cart)
      #total = sum(cart)
      #print('\nYour subscription will be a total of :',total)     
  
  main()
  del(cart)
  print(&quot;Goodbye and have a nice day!&quot;)
      
  </code></pre>
  <p>I need help in def Q2():
  I want the services that I have added to my cart referencing to the dictionary list to get the total sum.
  I'm not sure what is the exact codes. Please go easy on me, I'm a beginner.</p>
  <pre><code>def Q2():
      print(&quot;\nServices you have added:&quot;, cart)
      #total = sum(cart)
      #print('\nYour subscription will be a total of :',total)       
  </code></pre>