#๐ yo i need help with my python assignment i have finished all the code on it, just cannot debug thi
40 messages ยท Page 1 of 1 (latest)
@terse breach
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.
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
!code
import random
#Step 1 User info
stored_username = "student"
stored_password = "pythonmaster4335"
balance = random.randint(100,1000)
transaction_history = []
#step 2 login
print("Welcome to Galdames Bank !")
login_success = False
while login_succes == False:
username = input("Enter your username: ").strip()
password = input("Enter your password: ").strip()
if (username == stored_username) and (password == stored_password):
print(f"\n Welcome back, {username}!")
login_success = True
else:
print("\n Incorrect credentials. PLease try again \n")
#Step 3 Banking loop
while True:
print(f"Current balance is: ${balance}")
print("What would you like to do?")
print("1. Deposit")
print("2. Withdraw")
print("3. View Transaction History")
print("4. Logout")
choice = input("Choose an option (1-4) ").strip()
if choice == "1":
deposit = input("Enter a deposit number")
if deposit.isnumeric():
deposit = int(deposit)
if deposit > 0:
balance = balance + deposit
print("Deposit succesful ")
else:
print("Enter an amount over 0")
else:
print("Invalid input, enter only numbers")
#Withdraw
elif choice == "2":
withdraw = int(withdraw)
if withdraw > balance:
print("Insufficient funds")
elif withdraw <= 0:
print("Please enter an amount more than 0")
else:
balance = balance - withdraw
print("Withdraw succesful ")
#else:
# print("Invalid input. Enter 4 digits only")
elif choice == "3":
print("Your current balance is: $" + str(balance))
elif choice == "4":
print("Logging out. Thank you for banking with us")
break
else:
print("Invalid option, please choose 1, 2, 3, or 4")```
!indent
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
Yes
ive tried everything i know though and it didnt work
you think you could point out to me what isnt properly indented?
At least the bottom 6 line that isn't indented at all
Despite having if statement there
ik about those but they didnt even auto indent
its this code that is just completely buggin out
Why do you expect it definitely would auto indent? What are you using?
juicemind
all the if else elif while for all those statements auto indent
its for school
grade 11 class
It means that since python is an indentation sensitive language
You must have a consistent indentation
E.g. since rest of your code use 2 space indentation
Each level of indent should be 2 space
Could be
np
This help channel has been closed. 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.