#๐ Help
50 messages ยท Page 1 of 1 (latest)
@cyan wasp
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
class BankAccount:
def __init__(self, account_number, balance, owner):
self.account_number = account_number
self.balance = balance
self.owner = owner
def deposit(self, amount):
balance += amount
print(f"{amount} has been deposited into the account. The balance now is {balance}.")
def withdraw(self, amount):
balance -= amount
print(f"{amount} has been withdrawn from the account. The balance is now {balance}.")
def display_balance(self):
print(f"{balance}")
bankaccount1 = BankAccount(10002239929, 30,000,000, 'RedVersa')
bankaccount1.deposit(int(input("How much woud you like to deposit? ")))
bankaccount1.withdraw(int(input("How much would you like to withdraw? ")))
bankaccount1.display_balance()
you should update self.balance, not balance
in your deposit and withdraw
ok
and the display balance
those are the obvious problems that I can see
ok
you havn't mentioned what the actual problem is yet
it says I mentioned 4 parameters but It sees 6
ah I missed that
Traceback (most recent call last):
File "C:\Users\007\Documents\C++ and Py\Py\practice.py", line 18, in <module>
bankaccount1 = BankAccount(10002239929, 30,000,000, 'RedVersa')
TypeError: BankAccount.init() takes 4 positional arguments but 6 were given
this error
write 30,000,000 as 30_000_000

or just 30000000 but that's a bit hard to read
in your deposit, withdraw and display_balance functions, replace balance with self.balance
till the teacher catches me
ok
You should be asking your teacher for help
not coding teacher
a business studies one
Is this an exam?
coding python in school ๐
same
yeah, code is useful for other studies but only really when you're already good at code
fair enough
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ Help