Question: The instructions for this Python problem are here: https://docs.google.com/document/d/1xz-Q1FCc4DtyEpRyt3emNofBQle1HS9MeuUafqhLC8o/edit ________________________ This is my current code: _________________________ def getFile(): Function that gets file name from

The instructions for this Python problem are here: https://docs.google.com/document/d/1xz-Q1FCc4DtyEpRyt3emNofBQle1HS9MeuUafqhLC8o/edit

________________________

This is my current code:

_________________________

def getFile(): """ Function that gets file name from user """ # Reading file file = input(" Please enter a file name: "); try: # Opening file fileHandler = open(file, "w"); # If opened successfully, return handler return fileHandler;

except IOError: print(" The file " + file + " cannot be written to! "); # Calling function again return getFile(); def getAmount(): """ Function that reads amount from user """ # Variable to hold amount amount = 0.0; try: # Reading user input ip = input(" Amount: ") # Converting to float amount = float(ip); # Returning amount return amount;

except ValueError: print(" The amount, "+ ip + ", cannot be converted to a float! ");

return getAmount(); def main(): """ Main function """

fileHandler = getFile();

print(" Please enter sales data. Use a value of -1 for client name to exit. ");

while True:

client = input(" Client name: "); if client == "-1": break;

service = input(" Service: "); amount = getAmount(); date = input(" Date: "); fileHandler.write(client + "," + service + "," + str(amount) + "0000" + "," + date + " "); fileHandler.close();

main();

__________________________

These are the errors I'm getting:

The instructions for this Python problem are here: https://docs.google.com/document/d/1xz-Q1FCc4DtyEpRyt3emNofBQle1HS9MeuUafqhLC8o/edit ________________________ This is

my current code: _________________________ def getFile(): """ Function that gets file name

2: Compare output /sales.txt nput sales.txt -1 Please enter a file name The file /sales.txt cannot be written to! Your output Please enter a file name: Please enter sales data. Use a valuef -1 f r client name to exit. Client name: Please enter a filename: The file /sales.txt cannt be written to! Please try again... Expected output please enter a filename: Please enter sales data. Use a value of -1 for client name texit. Client name

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!