May-17-2018, 06:49 PM
This is early work in my book, so should be simple. I went and came up with some functions there, called finalDays, finalHours, and finalMinutes.
As you can see, I put them in the IF statements, intending them to work as I wish.
For some reason, the output from Python is always all three of them. So if I enter in a number less than 86400, or even less than 3600, I still get all three functions returned. What am I missing?
As you can see, I put them in the IF statements, intending them to work as I wish.
For some reason, the output from Python is always all three of them. So if I enter in a number less than 86400, or even less than 3600, I still get all three functions returned. What am I missing?
def TimeCalc(): #get the user to input the seconds userSeconds = int(input('Enter in the number of seconds to convert: ')) #create functions that will convert seconds into desired time period secondsToMinutes = round(userSeconds/60,4) secondsToHours = round(userSeconds/3600,4) secondsToDays = round(userSeconds/86400,4) #testing more functions. These are for the IF statements if I have to repeat them finalDays = print(userSeconds,' seconds into days is: ',secondsToDays) finalHours = print(userSeconds,' seconds into hours is: ',secondsToHours) finalMinutes = print(userSeconds,' seconds into minutes is: ',secondsToMinutes) #begin calculating the IF Then statements with the inputs and functions if userSeconds >= 86400: finalDays, finalHours, finalMinutes #print(userSeconds,' seconds into days is: ',secondsToDays) else: if userSeconds >=3600: finalHours, finalMinutes #print(userSeconds,' seconds into hours is: ',secondsToHours) else: if userSeconds >=60: finalMinutes #print(userSeconds,' seconds into minutes is: ',secondsToMinutes) #Call the TimeCalc Function TimeCalc()