#๐Ÿ”’ 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)

trail nacelleBOT
#

@terse breach

Python help channel opened

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.

terse breach
#

second screenshot of my code

#

the error

valid horizon
#

!paste

trail nacelleBOT
#
Pasting large amounts of code

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.

valid horizon
#

!code

trail nacelleBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

terse breach
#
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")```
valid horizon
#

!indent

trail nacelleBOT
#
Indentation

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

terse breach
#

i think thats the problem

#

indentation

valid horizon
#

Yes

terse breach
#

ive tried everything i know though and it didnt work

#

you think you could point out to me what isnt properly indented?

valid horizon
#

At least the bottom 6 line that isn't indented at all

#

Despite having if statement there

terse breach
#

ik about those but they didnt even auto indent

#

its this code that is just completely buggin out

valid horizon
#

Why do you expect it definitely would auto indent? What are you using?

terse breach
#

all the if else elif while for all those statements auto indent

#

its for school

#

grade 11 class

valid horizon
#

Well, just indent yourself tbf

#

It's basically just adding space character there

terse breach
#

hm ok that did something

#

but i really dont understand what this means

valid horizon
#

It means that since python is an indentation sensitive language
You must have a consistent indentation

terse breach
#

so code above line 50 arent indented properly

#

right?

valid horizon
#

E.g. since rest of your code use 2 space indentation
Each level of indent should be 2 space

valid horizon
terse breach
#

hm ok ill try something

#

omg

#

it works now

#

thank you SO much man

valid horizon
#

np

trail nacelleBOT
#
Python help channel closed for inactivity

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.