Question: While using this python program on cengage mindtap for programming exercise 4.12 it is not taking the hours worked and multiplying it by the Total

While using this python program on cengage mindtap for programming exercise 4.12 it is not taking the hours worked and multiplying it by the Total Pay of the person that is listed in a txt file.        Enter the file name: test.txt        Name          Hours    Total Pay        Lennon           12         3.33    McCartney        57         7.00    Harrison         11         9.10    Starr             3         4.13        filename = input("Enter the file name: ") # input the filename from the user        # declare lists for storing names, hours worked and total pays    names = []    hours = []    totalPay = []        # open the file    with open(filename, "r") as file:        lines = file.readlines() # read lines        # iterate over everyline        for line in lines:            line = line.split() # split the line by space to get a list of words            names.append(line[0]) # add the name from the line to the list            hours.append(int(line[1])) # append the integer(hours) from the line to the hours list            totalPay.append(float(line[2]))# append the float value of the total pay from the line to the totalPay list        print()    # print the header in the format    print(f'{"Name":14s}{"Hours":9s}{"Total Pay":13s}')        # iterate over the created lists and print the details in formatted manner    for name, hour, pay in zip(names, hours, totalPay):        print(f"{name:15s}{hour:4d}{pay:13.2f}")

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 Programming Questions!