Hi, I'm trying to build a simple python program that will total how many hours a worker has worked based on a start time and end time entry but the problem is this "simple" problem is becoming very complicated and i'm affraid i'm way off base and digging deeper and deeper into a coding nightmare... Think of it as a sort of time card system if you will.
I'm a beginner python coder (only been at it for 3 months now) if that helps explain my ignorance...
Specifically, I want the terminal operator to enter a start and end time in hh:mm format and have python then determine how many hours and minutes the worker worked based on his/her entries, then calculate the wage before taxes based on a pre-set wage variable. The program has to be able to identify either "am" or "pm" time and do the proper conversions.
Heres an example of the output i'm looking for (based on a $12.50/hr wage):
(red text is user input, green text is of course python)
>>> Please enter your start time (hh:mm): 12:30pm
>>> Please enter your end time (hh:mm): 6:00pm
>>> Total time worked: 6hrs 30min
>>> Total wages before taxes: $ 81.25
The problem i'm having, however, is figuring out how to make python calculate the correct amount of hours worked based on the hh:mm input from the user. I've done some string conversions, and splicing to isolate the hours and min into seperate variables but i'm geting lost in all the code. I'd like the resulting code to be simple and elegant.
Like, how do you tell python that from 12:30pm to 6:00pm equals 6 hours 30 min? Or from 7:30am to 4:45pm equals 9 hours 15 min and have that value multiplied by the wage?