Advertisement
barabar4e

Python Fundamentals /Lists Basics - Exercise / 09. Hello, France

Jan 31st, 2023
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. collection_of_items = input().split('|')
  2. budget = float(input())
  3.  
  4. bought_items_new_prices = []
  5. profit = 0
  6. new_price_of_merge_sum = 0
  7.  
  8. for item in collection_of_items:
  9.     elements = item.split('->')
  10.     type_of_merge = elements[0]
  11.     price_of_merge = float(elements[1])
  12.     if budget >= 150:
  13.         break
  14.     if budget < price_of_merge:
  15.         continue
  16.     if type_of_merge == 'Clothes' and price_of_merge <= budget:
  17.         if price_of_merge > 50.00:
  18.             continue
  19.     if type_of_merge == 'Shoes' and price_of_merge <= budget:
  20.         if price_of_merge > 35.00:
  21.             continue
  22.     if type_of_merge == 'Accessories' and price_of_merge <= budget:
  23.         if price_of_merge > 20.50:
  24.             continue
  25.  
  26.     budget -= price_of_merge
  27.     profit += price_of_merge * 0.4
  28.     new_price_of_merge = price_of_merge + (price_of_merge * 0.4)
  29.     new_price_of_merge_sum += new_price_of_merge
  30.     bought_items_new_prices.append(new_price_of_merge)
  31.  
  32. for element in bought_items_new_prices:
  33.     print(f'{element:.2f}', end=' ')
  34. print()
  35. print(f'Profit: {profit:.2f}')
  36. budget += new_price_of_merge_sum
  37. if budget >= 150:
  38.     print("Hello, France!")
  39. else:
  40.     print("Not enough money.")
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement