Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class bank:
- def __init__(self, balance, owner):
- self.balance = balance
- self.owner = owner
- def withdraw(self):
- amt = int(input(self.owner + ", how much would you like to withdraw?\n"))
- if amt < self.balance or amt == self.balance:
- print("You have successfully withdrawn", amt, "dollars!")
- self.balance = self.balance - amt
- print("You now have", self.balance, "dollars")
- elif amt > self.balance:
- print("You do not have enough money for this transaction!")
- def deposit(self):
- amt = int(input(self.owner + ", how much would you like to deposit?\n"))
- self.balance = self.balance + amt
- print("You now have", self.balance, "dollars!")
- def check_bal(self):
- return self.balance
- myacc = bank(100, "Redo")
- while True:
- area = input("\nWhat would you like to do? [Check Balance] [Deposit] [Withdraw] [Exit]\n")
- if area.lower() == "check balance":
- print("You have", myacc.check_bal(), "dollars!")
- elif area.lower() == "deposit":
- myacc.deposit()
- elif area.lower() == "withdraw":
- myacc.withdraw()
- elif area.lower() == "exit":
- print("Exiting. Goodbye!")
- break
- else:
- print("Invalid option. Try again.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement