You are on page 1of 2

class BankAccount:

def __init__(self, name, email, amount=0):

self.name = name

self.email = email

self.amount = amount

def deposit(self, amount):

self.amount += amount

print("Deposit successful. Current balance is:", self.amount)

def withdraw(self, amount):

if self.amount < amount:

print("Insufficient balance. Withdrawal failed.")

else:

self.amount -= amount

print("Withdrawal successful. Current balance is:", self.amount)

def show_details(self):

print("Name:", self.name)

print("Email:", self.email)

print("Current balance:", self.amount)

print("Welcome to the bank!")

while True:

choice = input("Do you want to create an account or exit? (create/exit): ")

if choice == "create":

name = input("Enter your name: ")

email = input("Enter your email: ")

amount = float(input("Enter the initial amount to deposit: "))


account = BankAccount(name=name, email=email, amount=amount)

break

elif choice == "exit":

print("Thank you for visiting the bank!")

exit()

while True:

print("What would you like to do?")

print("1. Deposit amount")

print("2. Withdraw amount")

print("3. Show account details")

print("4. Exit")

choice = int(input("Enter your choice (1/2/3/4): "))

if choice == 1:

amount = float(input("Enter the amount to deposit: "))

account.deposit(amount)

elif choice == 2:

amount = float(input("Enter the amount to withdraw: "))

account.withdraw(amount)

elif choice == 3:

account.show_details()

elif choice == 4:

print("Thank you for using our banking system!")

break

else:

print("Invalid choice. Please try again.")

You might also like