2

I'm learning Python, and this program worked fine, but suddenly i got a red line from the : at line 33 to the end of the program, with the error "illegal target for annotation". How could i fix this?

import turtle
import decimal
from decimal import Decimal
import sys
account_1_name = "John Smith"
account_1_balance = "67.58"
account_1_vault_balance = "200.00"
style = ('Calibri', 30)
password = input("What is your password?")
if password == "Cryptic":
    turtle.hideturtle()
    turtle.bgcolor("green")
    turtle.write("Access Granted.", font=style)
    turtle.done()
    prompt = input("""
    Welcome to Bank Network.

    Hello, %s
    Your balance is $%s
    Your savings account balance is $%s.

    type transfer to transfer money to savings section.      
    type deposit to deposit a check.""" % (account_1_name, account_1_balance , account_1_vault_balance))
    if prompt == "deposit":
            print("deposit system is down right now. Please try again later.")
            sys.exit(0)
    if prompt == "transfer":
        transfer_amount = input("How much do you want to transfer?")
        transfer_prompt = input("""
        are you sure you want to transfer money to your savings section?
        type cancel to cancel.
        type confirm to transfer"""
    if transfer_amount > account_1_balance:
        print("Not enough balance.")
    if transfer_amount < account_1_balance:
        print("Ok. Money transfered.")
        balance_post_transfer = Decimal(account_1_balance) - Decimal(transfer_amount)
        account_1_vault_balance_post_transfer = Decimal(account_1_vault_balance) + Decimal(transfer_amount)
        print("Your balance is now $%s and your savings account balance is $%s" % (balance_post_transfer, account_1_vault_balance_post_transfer))
if password != ("Cryptic"):
    turtle.hideturtle()
    print("access denied.")
    turtle.bgcolor("red")
    turtle.write("access denied.", font=style)
    turtle.done()
HasanQ
  • 75
  • 1
  • 3
  • 9

2 Answers2

1

From line 29 to 32, you have:

transfer_prompt = input("""
    are you sure you want to transfer money to your savings section?
    type cancel to cancel.
    type confirm to transfer"""

You didn't close the input. That is the reason of your error. Replace those lines by:

transfer_prompt = input("""
    are you sure you want to transfer money to your savings section?
    type cancel to cancel.
    type confirm to transfer""")
codrelphi
  • 1,075
  • 1
  • 7
  • 13
0

You will also get this false error if you have a ':' at the end of a line of code where it isn't supposed to be. :)

if name == 'main': write_sequence(filename='C:\Python\File_IO\recaman.txt', num=0)

if it's this the error shows up. I got in the habit of throwing this at the end of lines if it looked like some action is to be taken. if name == 'main': write_sequence(filename='C:\Python\File_IO\recaman.txt', num=0):

user1585204
  • 827
  • 1
  • 10
  • 14