Advertisement
sibinasto

Problem 2 - Clothes and Shoes

Mar 7th, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. product_and_price = input().split('|')
  2. budget = int(input())
  3. new_list = []
  4. profit = 0
  5. new_budget = 0
  6.  
  7. for product in product_and_price:
  8.     token = product.split('->')
  9.     item = token[0]
  10.     price = float(token[1])
  11.     if item == "Clothes" and price <= 50 and budget - price >= 0:
  12.         budget -= price
  13.         new_price = round(price * 1.40, 2)
  14.         new_list.append(new_price)
  15.         profit += new_price - price
  16.     elif item == "Shoes" and price <= 35 and budget - price >= 0:
  17.         budget -= price
  18.         new_price = round(price * 1.40, 2)
  19.         new_list.append(new_price)
  20.         profit += new_price - price
  21.     elif item == "Accessories" and price <= 20.50 and budget - price >= 0:
  22.         budget -= price
  23.         new_price = round(price * 1.40, 2)
  24.         new_list.append(new_price)
  25.         profit += new_price - price
  26.  
  27. for i in new_list:
  28.     print(f"{i:.2f}", end=" ")
  29. print()
  30.  
  31. new_budget = sum(new_list) + budget
  32. print(f"Profit: {profit:.2f}")
  33. if new_budget >= 150:
  34.     print("Hello, France!")
  35. else:
  36.     print("Time to go.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement