title: Slot machine program in python
body: <p>I need my program to return the sum of money spent and the sum of the prizes won at the end of the program after user enters 'N' to stop playing, but in my example it is only returning the last values entered.</p>
  <pre><code>import random
  
  
  def calculate_winnings(winning_combos):
  
      spend = float(input(&quot;Enter money to bet: &quot;))
      total_spent = []
      total_spent.append(spend)
      total_prize = []
      
      print(winning_combos)
  
      #calculate user winnings
  
      if winning_combos[0] == winning_combos[1] and winning_combos[1] == winning_combos[2]:
          prize = spend * 3
          total_prize.append(prize)
          print(f'You got three matches and you won $ {prize}')
      elif winning_combos[0] == winning_combos[1] or winning_combos[1] == winning_combos[2] or winning_combos[0] == winning_combos[2]:
          prize = spend * 2
          total_prize.append(prize)
          print(f'You got two matches and you won $ {prize}')
      else: 
          print(f'You did not win. Prize is $0') 
      
      play = input(f'WWWWould you like to play? Enter Y for yes and N for no: ').upper()
      while play == 'Y':
          calculate_winnings(winning_combos)
      if play == 'N':
          print(f'total spent {sum(total_spent)} and total won {sum(total_prize)}')
          print('end game.')
  
  #loop through game as many times as user wants
  
  def main():
  
      # slot machine values
      
      slot_machine_values = ['Cherry', 'Orange', 'Plums', 'Bell', 'Melon', 'Bar']
      winning_combos = []
      #calculate random values from above list
      for x in range(3):
          winning_value = random.choice(slot_machine_values)
          winning_combos.append(winning_value)
      
      calculate_winnings(winning_combos)
  
  
  main()
  </code></pre>