0
class timeDifference:
    def __init__(self, sal=0):
    
        self.sal = sal
        if self.sal == 0:
            pass
        elif self.sal == 1:
            salory = input("Salory (per hour): ")

        #imports
        import datetime

        #defining the Start and End times
        while True:
             timeStart = input("Start time: ")
             timeEnd = input("End time: ")
             if len(timeStart) & len(timeEnd) == 4:
                break
             else:
                print("Error 001: only 4 integers allowed! (hh/mm)")


        #defining the hours
        timeStartH = timeStart[0:2]
        timeEndH = timeEnd[0:2]
        #defining the minutes
        timeStartM = timeStart[2:4]
        timeEndM = timeEnd[2:4]

        #converting strings to ints for math
        v = int(timeStartH)
        v1 = int(timeEndH)
        v2 = abs(v - v1)

        z = int(timeStartM)
        z1 = int(timeEndM)
        z2 = abs(z - z1)
        
        #calculating money earned
        money = v2*salory
        print("~$", money)
        
        #printing the difference between times
        print(datetime.time(v2, z2))

Everything works fine until the money variable decides to say that 6*2 is 6 2s...

The script is supposed to let me input a work shift and have it tell me how long it is and how much I will make from it. However, it obviously screws up on the money part

I feel like this is a simple problem with a simple solution, but I can't find it :/

Barmar
  • 741,623
  • 53
  • 500
  • 612

0 Answers0