Advertisement
anton_d

09.hello_frrance

Sep 19th, 2022
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. collection_of_items = input().split("|")
  2. budget = int(input())
  3. budget_left = budget
  4. train_ticket = 150
  5. total_money = 0
  6. items_bought = []
  7.  
  8.  
  9. def add_money(current_price):
  10.     global total_money, budget_left
  11.     total_money += current_price
  12.     budget_left -= current_price
  13.  
  14.  
  15. for index in collection_of_items:
  16.     current_item, current_price = [float(x) if x[-1].isdigit() else x for x in index.split('->')]
  17.     if budget_left >= current_price:
  18.         if current_item == 'Clothes' and current_price <= 50:
  19.             add_money(current_price)
  20.             items_bought.append(current_price + (current_price * 0.40))
  21.         elif current_item == 'Shoes' and current_price <= 35:
  22.             add_money(current_price)
  23.             items_bought.append(current_price + (current_price * 0.40))
  24.         elif current_item == 'Accessories' and current_price <= 20.50:
  25.             add_money(current_price)
  26.             items_bought.append(current_price + (current_price * 0.40))
  27.  
  28. difference = sum(items_bought) - total_money
  29. print(' '.join(f"{n:.2f}" for n in items_bought))
  30. print(f'Profit: {difference:.2f}')
  31. if budget + difference > train_ticket:
  32.     print('Hello, France!')
  33. else:
  34.     print('Not enough money.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement