#πŸ”’ Simple bank program is looping endlessly?

14 messages Β· Page 1 of 1 (latest)

cyan cliff
#

I am trying to make a simple banking program with check balance, withdraw, deposit, and exit options. It is endlessly looping. I am just currently trying to be able to input a β€œchoice” value of 1-4.

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”-β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

Python Banking Program

def show_balance():
pass

def deposit():
pass

def withdraw():
pass

balance = 0
is_running = True

while is_running:
print("Banking Program")
print("1. Check Balance")
print("2. Deposit")
print("3. Withdrawal")
print("4. Exit")

choice = input("Enter your choice (1-4)")

if choice == "1":
show_balance()

elif choice == "2":
deposit()

elif choice == "3":
withdraw()

elif choice == "4":
is_running = False

else:
print("Your choice is not valid.")

thin fableBOT
#

@cyan cliff

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.

hybrid igloo
#

Also, instead of is_running you could just say while True: and use break instead of setting it to False, but that doesn't really matter too much.

rugged topaz
#

Your choise...if/eif/... is outside the loop.

cyan cliff
rugged topaz
#

Indent it the same as the prints for the menu.

floral creek
#

^ this is the way

cyan cliff
hybrid igloo
#

You can put it in a code block with
```python
code
```

cyan cliff
#

Appreciate both of your help

cyan cliff
thin fableBOT
#
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.