Bank account · 銀行口座
Bank account
A tiny bank that follows a list of instructions and never lets the balance go below zero.
"deposit 50".split() breaks the string at its spaces into ["deposit", "50"]. The amount is still text, so convert it with int(). Check that there is enough money before a withdrawal changes the balance; a refused withdrawal simply does nothing.
バンク口座
指示リストに従って動作し、残高がゼロを下回らないようにする小さな銀行です。
"deposit 50".split() はスペースで文字列を ["deposit", "50"] に分割します。金額は依然としてテキストなので、int() で変換してください。引き出し操作によって残高が変わる前に、資金が十分か確認します。拒否された引き出しは何も行いません。
Write final_balance(actions). Each action is a string such as "deposit 50" or "withdraw 20". Start at 0, apply the actions in order, and refuse any withdrawal that would take the balance below 0. Return the final balance. · final_balance(actions)を記述する。各アクションは"deposit 50"や"withdraw 20"のような文字列である。0から始め、アクションを順に適用し、残高が0を下回る引き出しは拒否する。最終残高を返す。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。