fork download
  1. class shopping_cart():
  2.  
  3.  
  4. def __init__(self , events):
  5. self.events = events
  6.  
  7. def pricing(self):
  8. total = 0
  9. if self.events.count("OH") > 2:
  10. total += (self.events.count("OH") - 1) * 300
  11. else:
  12. total += self.events.count("OH") * 300
  13. if self.events.count("SK") > self.events.count("OH"):
  14. total += ( self.events.count("SK") - self.events.count("OH") ) * 30
  15. if self.events.count("BC") > 4:
  16. total += self.events.count("BC") * 110 - 20
  17. else:
  18. total += self.events.count("BC") * 110
  19. print(total , "$")
  20.  
  21.  
  22. tours = [ "OH OH OH BC SK" , "OH BC BC SK SK" , "BC BC BC BC BC BC OH OH" , "SK SK BC" ]
  23.  
  24. for i in tours:
  25. tour = shopping_cart(i)
  26. print(i , " = " , end="")
  27. tour.pricing()
Success #stdin #stdout 0.02s 28376KB
stdin
Standard input is empty
stdout
OH OH OH BC SK  = 710 $
OH BC BC SK SK  = 550 $
BC BC BC BC BC BC OH OH  = 1240 $
SK SK BC  = 170 $