Advertisement
bl00dt3ars

10. Bread Factory (Penka Petkova)

Jul 2nd, 2021
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. energy = 100
  2. coins = 100
  3. working_day = input().split("|")
  4.  
  5. for com in working_day:
  6.     lists = com.split("-")
  7.     command = lists[0]
  8.     number = int(lists[1])
  9.  
  10.     if command == "rest":
  11.         if energy + number <= 100:
  12.             energy += number
  13.             print(f"You gained {number} energy.")
  14.         else:
  15.             print(f"You gained {100 - energy} energy.")
  16.             energy = 100
  17.         print(f"Current energy: {energy}.")
  18.     elif command == "order":
  19.         if energy - 30 >= 0:
  20.             coins += number
  21.             energy -= 30
  22.             print(f"You earned {number} coins.")
  23.         else:
  24.             energy += 50
  25.             print("You had to rest!")
  26.     else:
  27.         coins -= number
  28.         if coins > 0:
  29.             print(f"You bought {command}.")
  30.         else:
  31.             print(f"Closed! Cannot afford {command}.")
  32.             exit()
  33.  
  34. print("Day completed!")
  35. print(f"Coins: {coins}")
  36. print(f"Energy: {energy}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement