<Below this line, add a link to the EXACT exercise that you are stuck at.>
if CHOICE == 1
<In what way does your code behave incorrectly? Include ALL error messages.>
syntax error after first iteration.
<What do you expect to happen instead?>
Not sure why it isn’t running since it seems to have proper syntax.
```python
input(“Enter your Account Number”)
print (“Current Account Balance: 25000”)
strCHOICE = input (“Press 1 to make a Deposit or 2 to make a Withdrawal.”)
if CHOICE == 1
strDEPOSIT = input(“Press 1 to deposit to checking, 2 for savings”)
if DEPOSIT = 1
print(“Please insert check or money now”)
elif DEPOSIT = 2
print(“Please insert check or money now”)
elif CHOICE == 2
strWITHDRAWAL = input(“press 1 to draw funds from checking, press 2 for savings.”)
if WITHDRAWAL = 1
input(“How much would you like to withdraw today?”)
print(“Please remove your cash from the slot below”)
elif WITHDRAWAL = 2
input(“How much would you like to withdraw today?”)
print(“Please remove your cash from the slot below”)
endofprogram = input(“Thank you for your business, press enter to conclude this transaction.”)
This was not a specific lesson in codeacademy. I’m trying to just do some simple exercises on my own from the lessons here.
The colons definitely helped. I’m still getting a syntax error on the next if iteration [if DEPOSIT = 1:]. The error is on the equal sign but since 1 is a true condition, not sure why the syntax error.
Hey thanks, Gandalf. So in this instance I’m actually comparing values since there is the option between integers 1 and 2? Is that why I should use ==?
I gotcha. Ok, that’s actually helpful. I knew that theoretically, but having it explained that way more clearly demonstrates the difference.
Well the program at least runs now. But once the program runs and I’m asked to select 1 or 2 for deposit, an error generates. Is this because I haven’t set an int value after [if DEPOSIT == 1:]? I feel like I’m missing something that will turn the input into a value.
I tried working that out, but I don’t see how they are different. Are you referring to the first IF statement? CHOICE?
if CHOICE == 1:
strDEPOSIT = input(“Press 1 to deposit to checking, 2 for savings”)
if DEPOSIT == 1:
print(“Please insert check or money now”)
elif DEPOSIT == 2:
print(“Please insert check or money now”)
According to the line errors I’m getting I need to define most of these variables and I’m just not sure how. It tells me CHOICE isn’t defined, but I thought it was defined by the input string on line 4. I tried adding CHOICE = 1 which got me further but I realized that means CHOICE can’t equal 2. So I tried “1 or 2” but that didn’t seem to help. Any suggestions are immensely helpful. Thanks.
Current program:
input("Enter your Account Number: ")
print(“Current Account Balance: 25000”)
strCHOICE = input(“Press 1 to make a deposit or 2 to make a withdrawal.”)
if CHOICE == 1:
strDEPOSIT = input("Press 1 to deposit to checking, 2 for savings: ")
if DEPOSIT == 1:
print(“Please insert cash or checks into checking.”)
elif DEPOSIT == 2:
print(“Please insert cash or checks into savings.”)
elif CHOICE == 2:
strWITHDRAWAL = input(“press 1 to draw funds from checking, press 2 for savings.”)
if WITHDRAWAL == 1:
input(“How much would you like to withdraw today?”)
print(“Please remove your cash from the slot below”)
elif WITHDRAWAL == 2:
input(“How much would you like to withdraw today?”)
print(“Please remove your cash from the slot below”)
endofprogram = input(“Thank you for your business, press enter to conclude this transaction.”)
I was not defining CHOICE as an int input and left it as a regular input string. I then copied this to the rest of the variables and it worked.
Thank you again!
–
input("Enter your Account Number: ")
print(“Current Account Balance: 25000”)
CHOICE = int(input("Press 1 to make a deposit or 2 to make a withdrawal: "))
if CHOICE == 1:
DEPOSIT = int(input("Press 1 to deposit to checking, 2 for savings: "))
if DEPOSIT == 1:
print(“Please insert cash or checks into checking.”)
elif DEPOSIT == 2:
print(“Please insert cash or checks into savings.”)
elif CHOICE == 2:
WITHDRAWAL = int(input(“press 1 to draw funds from checking, press 2 for savings.”))
if WITHDRAWAL == 1:
input(“How much would you like to withdraw today?”)
print(“Please remove your cash from the slot below”)
elif WITHDRAWAL == 2:
input(“How much would you like to withdraw today?”)
print(“Please remove your cash from the slot below”)
endofprogram = input(“Thank you for your business, press enter to conclude this transaction.”)