ATM with function


I’m sorry to change codes but this is my method to understund things :blush:
Here I’m just added the input, it looks more logical if customer wants to choose his request by itself…
but the problem is how to use the last balance to do a new request.

some suggestion Sir @YaserAlnajjar

I tried to do in the last:

balance -= balance

but I will find balance = 0 by this way

request = raw_input("put your request : ")
request = int(request)

def give(request, amount):
   print ("give " + str(amount))
   return request - amount

def do_request(balance, request):
   balance -= request

   amounts = [100, 50, 10, 5, 1]
   while (request > 0):
       for amount in amounts:
           if (request >= amount):
               if amount == 1:
                   amount = request
               request = give(request, amount)
   return balance

def withdraw(balance, request):
   if (not isinstance(balance, int) or not isinstance(request, int)):
       print ("Inputs must be numbers")
   elif (request <= 0):
       print ("Request must be greater than 0")
   elif (request > balance):
       print ("You don't have enough funds")
       return do_request(balance, request)

balance = 500
balance = withdraw(balance, request)

print ("Your balance : " + str(balance))


you already returned the new balance so you can simply say

balance = 500

balance = withdraw(balance, 200)
balance = withdraw(balance, 300)

cuz you set the balance each time you call withdraw function


OK :ok_hand: Thank you sir @YaserAlnajjar,


I’m learning flask , Please Sir @YaserAlnajjar Did you have the course about what you did in the forum of OMAC ?
I have the link of your correction of the forum’s workshop by Django,
But I want to read your lessons about framework.


Here are the old lessons:

If you find anything missing, please lemme know :wink:


Wonderful :heart_eyes: sure Sir @YaserAlnajjar :ok_hand: