هذا ا تم طباعته قبل التنقيح
the value of balance is : 500
sorry we do not have enough money for your request
-200
لكن بعد تنقيح البرمجيات بهذه الطريقة
def withdraw( balance, request ):
result = balance
print( "the value of balance is : ", balance)
if request > balance :
print( "sorry we do not have enough money for your request" )
elif request < 0 :
print( "more than o, please")
elif request < balance :
while request > 0 :
if request >= 100 :
request -=100
print("give 100")
elif request >=50 :
request -=50
print( "give 50" )
elif request >= 10 :
request -=10
print( "give 10" )
elif request >= 5 :
request -=5
print( "give 5" )
elif request < 5 :
print( "give" + str(request))
request = 0
result = balance - request
else :
print( "we can not provide this service" )
return result
balance = 500
balance = withdraw( balance, 700 )
print (balance)
كانت النتيجة كالتالي
the value of balance is : 500
sorry we do not have enough money for your request
500
وفي حالة الطلب اقل من الرصيد ونقل تعريف الناتج الى ما قبل الحلقة كانت الطباعة كالتالي
the value of balance is : 500
give 100
400