Advertisement
Spocoman

Trip Expenses

Oct 5th, 2023
1,010
-1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 1
  1. days = int(input())
  2. day_cash = 0
  3.  
  4. for i in range(days):
  5.     day_products = 0
  6.     day_cash += 60
  7.  
  8.     while True:
  9.         command = input()
  10.         if command == "Day over":
  11.             print(f"Money left from today: {day_cash:.2f}. You've bought {day_products} products.")
  12.             break
  13.  
  14.         product_price = int(command)
  15.         if product_price <= day_cash:
  16.             day_cash -= product_price
  17.             day_products += 1
  18.  
  19.         if day_cash == 0:
  20.             print(f"Daily limit exceeded! You've bought {day_products} products.")
  21.             break
  22.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement