Python Forum
I have two Same Code but One of them Doesnt Work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I have two Same Code but One of them Doesnt Work
#1
Hello everyone.. I have a problem
I have two Same Code but One of them Doesnt Work

This is the one that doesnt work
balance=1000
## 1= BALANCE CHECK
## 2= deposit money
## 3= withdraw money
## q= exit
while True:
     operation= input("Choose Operation:")

    if (operation == "q"):
        print("signing out...")
        break
    elif (operation == "1"):
        print("current balance: ",balance)
    elif (operation == "2"):
        money = int(input("amount deposited: "))
        balance += money
        print("current balance: ",balance)

    elif (operation == "3"):
        money = int(input("the amount you want to withdraw: ")
        if (balance-money<0):
            print("You dont have enough money")
            continue
        balance -= money
    else:
        print("Invalid operation, (choose 1,2 or 3")
but this code is working even though both are same

balance=1000
## 1= BALANCE CHECK
## 2= deposit money
## 3= withdraw money
## q= exit
while True:
    operation = input("Choose Operation:")

    if (operation == "q"):
        print("signing out...")
        break
    elif (operation == "1"):
        print("current balance:  ", balance)
    elif (operation == "2"):
        money = int(input("amount deposited:"))
        balance += money
        print("current balance: ", balance)

    elif (operation == "3"):
        money = int(input("the amount you want to withdraw:"))
        if (balance - money < 0):
            print("You dont have enough money")
            continue
        balance -= money

    else:
        print("Invalid operation, (choose 1,2 or 3")
Please help me ...... Angry
I've been working for hours for this.
Reply


Messages In This Thread
I have two Same Code but One of them Doesnt Work - by beginner721 - Jan-22-2021, 04:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  print doesnt work in a function ony 2 303 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  Pydoc documentation doesnt work Cosmosso 5 4,382 Nov-25-2023, 11:17 PM
Last Post: vidito
  hi need help to make this code work correctly atulkul1985 5 792 Nov-20-2023, 04:38 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 694 Oct-22-2023, 09:08 PM
Last Post: tronic72
  pip install requests doesnt work misodca 8 6,153 Jul-07-2023, 08:04 AM
Last Post: zyple
  Beginner: Code not work when longer list raiviscoding 2 823 May-19-2023, 11:19 AM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,795 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  Code used to work 100%, now sometimes works! muzicman0 5 1,447 Jan-13-2023, 05:09 PM
Last Post: muzicman0
  color code doesn't work harryvl 1 893 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  Ldap3 Python print(conn.entries) doesnt work ilknurg 15 5,774 Dec-28-2022, 11:22 AM
Last Post: shad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020