Question: I have a financial system and I have to design a module for save, update and control limitation. 
You can know each customer has a UserID and each UserID has a maximum amount of credit per day. For example, **UserID = 12 has MaxAmountPerDay = 10$** and **CurrentAmountPerDay**.

At first, I wanted to design a simple module and define a table as follows:

```
  User ID | MaxAmountPerDay | CurrentAmountPerDay
-------------------------------------------------
  12     | 10              | 0
  25     | 100             | 84

```

Now you can imagine when the customer with **UserID = 12** has done a transaction I have to control if the **transaction amount + current amount > max amount** then throw an exception else I have to do the transaction and update current amount and when an exception happened after updating I have to rollback the update operation.(update and rollback are in different database transactions so the rollback is the same update with new amount)

Before I do this design I decided to look up for a better solution or even an open source framework for doing that because I guess my customer's requirements will change in future, for example maybe they will need to **MaxAmountPerMonth**, or some more requirements which I don't know now.

Answer: 
Assuming the input is a *string*, you can do this:

```
number_str = '0730'
time_str = number_str[:2] + ':' + number_str[2:]
print(time_str)  # Output: '07:30'

```
All of these require 4 digits for your time. This code will add a zero to the front if there are 3 digits. It will check for invalid times.

```
def conv_num_time(time):
num_str = ('{:04}'.format(time))
time_str = num_str[:2] + ':' + num_str[2:]
if int(num_str[:2])>23 or int(num_str[2:])>59:
    print("Invalid time")
else:
    print(time_str)
user_time = int(input(': '))
conv_num_time(user_time)

```