Python Forum

Full Version: Error when trying to run a stopwatch
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Im getting an error when running this def and im not sure why. Its meant to be a stopwatch that runs and counts during what ever code you set it to start on.

def stopWatch(value):
    '''From seconds to Days;Hours:Minutes;Seconds'''

    valueD = (((value/365)/24)/60)
    Days = int (valueD)

    valueH = (valueD-Days)*365
    Hours = int(valueH)

    valueM = (valueH - Hours)*24
    Minutes = int(valueM)

    valueS = (valueM - Minutes)*60
    Seconds = int(valueS)

    print("and you finished in", Days "days", Hours "Hours", Minutes "Minutes", Seconds "Seconds")


start = time.time() # What in other posts is described is

input("test ")

end = time.time()         
stopWatch(end-start) #Use then my code
You should state the error you are getting.
The time module is being used but has not been imported.
There are syntax errors in your print statement due to using a variable followed by a space followed by a string.