Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Better than two holiday functions in https://www.youtube.com/watch?v=0U-RwnWaFIM
- HOLIDAY_CONFIG = {
- "single": {"days": 1, "msg": "Have fun on your holiday..."},
- "payout": {"days": 5, "msg": "Paying out a holiday. Left: {remaining_days}"},
- }
- def take_holiday(self, holiday_type: str) -> None:
- config = HOLIDAY_CONFIG[holiday_type] # Raises KeyError if invalid
- if self.vacation_days < config["days"]:
- raise ValueError(f"Not enough holidays for {holiday_type}.")
- self.vacation_days -= config["days"]
- print(config["msg"].format(remaining_days=self.vacation_days))
Advertisement
Add Comment
Please, Sign In to add comment