Python while moon

Asked 1 years ago, Updated 1 years ago, 72 views

( elif num == 2: ^ SyntaxError: invalid syntax) It pops up like this and there is a red mark on this part, so how do I solve it?

money = 0

  while True:



    num = int (input ("select the menu :"))
    if num == 1:
        money2 = int (input ("deposit amount :"))
    money = money + money2

    elif num == 2:
        money3 = int(input("withdrawal :"))
    while money3 > money:
        money3 =int(intput)
        money3 = int (input ("withdrawal :"))
        money = money - money3
    elif num ==3:
        print("Balance :", money)
    elif num == 4:
        print ("End of Program")
        break

python while-loop input

2022-09-21 11:15

1 Answers

Indentation is very important in Python. Pay attention to this.

money = 0
while True:
    num = int (input ("select the menu :"))
    if num == 1:
        money2 = int (input ("deposit amount :"))
        money = money + money2
    elif num == 2:
        money3 = int(input("withdrawal :"))
        while money3 > money:
            money3 =int(intput)
            money3 = int (input ("withdrawal :"))
            money = money - money3
    elif num ==3:
        print("Balance :", money)
    elif num == 4:
        print ("End of Program")
        break


2022-09-21 11:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.