Today we will see the ** HackerRank Day 26 Solution in Python**. The problem is named

**which is part of**

*Nested Logic***. Let’s get started!**

*30 Days of code on HackerRank*## Day 26: Nested Logic Problem statement

We are given the expected and actual return dates for a library book, and we have to create a program that calculates the fine (if any). The fee structure is as follows:

- If the book is returned on or before the expected return date, no fine will be charged (i.e.:fine=0)
- If the book is returned after the expected return
*day*but still within the same calendar month and year as the expected return date, fine=15 hackos X number of days late. - If the book is returned after the expected return
*month*but still within the same calendar year as the expected return date, the fine=500 hackos X number of days late. - If the book is returned after the calendar
*year*in which it was expected, there is a fixed fine of 10000.

**Sample Input**

```
9 6 2015
6 6 2015
```

**Sample Output**

`45`

You can solve the problem here.

## HackerRank Day 26 Solution in Python

#Get the input d1, m1, y1 = map(int, input().split()) d2, m2, y2 = map(int, input().split()) #If returned year is less than due year if y1 < y2: print(0) #If returned year is equal to due year elif y1 == y2: #If returned month is less than due month if m1 < m2: print(0) #If returned month is equal to due month elif m1 == m2: #If returned day is less than due day if d1 <= d2: print(0) else: print(15*(d1-d2)) else: print(500*(m1-m2)) else: print(10000)

## Code Explanation

- First, get the two input dates and split them into the day, month, and year
- d1, m1, y1 corresponds to the returned date and d2,m2,y2 corresponds to the due date
- Then check the respective conditions given in the problem statement and print the output

**Also Read:**

- HackerRank Day 8 Solution in Python: Dictionaries and Maps
- HackerRank Day 7 Solution in Python: Arrays
- HackerRank Day 6 Solution in Python: Let’s review
- HackerRank Day 5 Solution in Python: Loops
- HackerRank Day 4 Solution in Python: Class vs Instance
- HackerRank Day 3 Solution in Python: Intro to Conditional Statements
- HackerRank Day 2 Solution in Python: Operators
- HackerRank Day 1 Solution in Python: Data Types
- HackerRank Day 0 Solution in Python: Hello World
- HackerRank Day 29 Solution in Python: Bitwise AND
- HackerRank Day 28 Solution in Python: RegEx, Patterns, and Intro to databases
- HackerRank Day 27 Solution in Python: Testing
- HackerRank Day 26 Solution in Python: Nested Logic
- HackerRank Day 25 Solution in Python: Running Time and Complexity
- HackerRank Day 24 Solution in Python: More Linked Lists
- HackerRank Day 23 Solution in Python: BST Level Order Traversal
- HackerRank Day 22 Solution in Python: Binary Search Trees
- HackerRank Day 20 Solution in Python: Sorting
- HackerRank Day 19 Solution in Python: Interfaces
- HackerRank Day 18 Solution in Python: Queues and Stacks
- HackerRank Day 17 Solution in Python: More Exceptions
- HackerRank Day 16 Solution: Exceptions – String to Integer
- HackerRank Day 15 Solution in Python: Linked List
- HackerRank Day 13 Solution in Python: Abstract Classes
- HackerRank Day 14 Solution in Python: Scope
- HackerRank Day 12 Solution in Python: Inheritance
- HackerRank Day 11 Solution in Python: 2D Arrays
- HackerRank Day 10 Solution in Python: Binary Numbers