Advertisement
GeorgiLukanov87

03.angry_cat

Jun 26th, 2022
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # 03. Angry Cat , Mid Exam Fundamentals Python June.2022
  2.  
  3.  
  4. ratings = list(map(int, input().split(', ')))
  5. start_index = int(input())
  6. type_items = input()
  7. left_side = ratings[:start_index][::-1]
  8. right_side = ratings[start_index+1:]
  9.  
  10. left_damage = []
  11. right_damage = []
  12. entry_point = ratings[start_index]
  13.  
  14. for item in left_side:
  15.     if type_items == 'cheap':
  16.         if item < entry_point:
  17.             left_damage.append(item)
  18.     elif type_items == 'expensive':
  19.         if item >= entry_point:
  20.             left_damage.append(item)
  21.  
  22. for item in right_side:
  23.     if type_items == 'cheap':
  24.         if item < entry_point:
  25.             right_damage.append(item)
  26.     elif type_items == 'expensive':
  27.         if item >= entry_point:
  28.             right_damage.append(item)
  29.  
  30. if sum(left_damage) >= sum(right_damage):
  31.     print(sum(left_damage))
  32. else:
  33.     print(sum(right_damage))
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement