Question: I have lot of errors can someone help fix Below is a copy # Given the fields have one blank space between them def get_number(line):

I have lot of errors can someone help fix

I have lot of errors can someone help fix Below is a

copy # Given the fields have one blank space between them def

get_number(line): return line.split(" ")[0] def get_balance(line): return float(line.split(" ")[1]) def get_name(line): return

Below is a copy

# Given the fields have one blank space between them def get_number(line): return line.split(" ")[0]

def get_balance(line): return float(line.split(" ")[1])

def get_name(line): return line[17:]

def main(): filename= input("Enter a file prefix: ") try: f= open(filename+"_old.txt","r") n= open(filename+"_new.txt","a") for line in f: if line!="999999": number= get_number(line.strip()) balance= get_balance(line.strip()) name = get_name(line.strip()) print("Verifying input: ",line) command= input("Enter a command (a,c,d,w) :")[0] while command =='w' or command =='d': if command !="w" and command !="d" and command !="a" and command !="c": print("Entered an invalid command :",command) command= input("Enter a command(a,c,d,w):")[0] if command =='w': amt= int(input("Enter withdrawal amount: ")) balance=balance-amt else: amt= int(input("Enter the amount to be deposited:")) balance= balance+amt command = input("Enter a command (a,c,d,w) :")[0] if command=='a': print("New balance: {} {} {}".format(number,balance,name)) s1= number+" "+str(balance)+" "+name n.write(s1+" ") else: if balance!=0: print("Account not closed because money is still in it") s1 = number + " " + str(balance) + " " + name n.write(s1+" ") else: print("Account is closed")

n.close() except IOError: print("The file name {}_old.txt does not exist".format(filename))

if __name__=="__main__": main()

e Unresolved reference 'filename':13 Unresolved reference 'filename':14 Indent expected :23 O 'except' or 'finally' expected :23 e Indent expected :23 Statement expected, found Py:ELSE_KEYWORD :29 Statement expected, found Py:COLON :29 Indent expected :34 Statement expected, found Py:ELSE_KEYWORD :37 Statement expected, found Py:COLON :37 e Indent expected :39 Statement expected, found Py:ELSE_KEYWORD :42 Statement expected, found Py:COLON :42 Unexpected indent :46 Statement expected, found Py:EXCEPT_KEYWORD :46 Expression expected :46 Statement expected, found Py:DEDENT :46 Unresolved reference 'filename':47 A Name 'line' can be undefined :20 A Name 'balance' can be undefined :28 A Name 'amt' can be undefined :28 A Name 'number' can be undefined :34 A Name 'name' can be undefined :34 A Shadows name 'line' from outer scope :1 A Shadows name 'line' from outer scope :4 A Shadows name 'line' from outer scope :7 A Local variable 'filename' value is not used :11 A Shadows built-in name 'IOError' :46 emain.py customers_old.txt x : 1 Edef get_number(line): 2 A return line.split(" ")[0] 3 4 Edef get_balance(line): 5 return float(line.split(" ")[1]) 6 7 Edef get_name(line): return line[17:] 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Edef main(): A filename= input("Enter a file prefix: ") Etry: f= open(filename+"_old.txt","") n= open(filename+"_new.txt", "a") for line in f: if line!="999999": number= get_number(line.strip()) balance= get_balance(line.strip()) name = get_name(line.strip()) print("Verifying input: ", line) command= input("Enter a command (a,c,d,w) :")[0] while command =='w' or command == 'd': A if command !="W" and command !="d" and command !="a" and command !="C":. print("Entered an invalid command :",command) command= input("Enter a command(a,c,d,w):")[0] if command == 'w': amt= int(input("Enter withdrawal amount: ")) balance-balance-amt else: amt= int(input("Enter the amount to be deposited:")) balancer balance+amt command = input("Enter a command (a,c,d,w) :")[0] if command=='a': print("New balance: {} {} {}".format(number, balance, name)) 23 24 25 26 27 28 29 30 31 32 33 34 34 35 36 37 38 print("New balance: {}_{}_{}".format(number, balance, name)) s1= number+" "+str(balance)+" "+name n.write(S1+" ") else: if balance!=0: print("Account not closed because money is still in it") s1 = number + + str(balance) + n.write(s1+" ") else: print("Account is closed") 39 40 + name 41 42 43 44 45 46 n.close() except IOError: #

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!