+ 1

Converting Seconds into days, hours, minutes, and seconds and printing them , There 's a syntax error (Can't assign to literal)

a = input ("Type an integer (in Seconds):") b = int (a) sec_in_day = 24*60*60 sec_in_hour = 60*60 sec_in_minute = 60 if b > sec_in_day : days= b // sec_in_day hours =( b % sec_in_aday ) // sec_in_hour minutes = (( b % sec_in_day ) % sec_in_hour ) // sec_in_minute seconds = (( b % sec_in_day ) % sec_in_hour ) % (sec_in_minute) elif b > sec_in_hour : days= 0 hours = b // sec_in_hour minutes = ( b % sec_in_hour) // 60 seconds = ( b % sec_in_hour) % 60 elif b > sec_in_minute : days= 0 hours = 0 minutes = b // sec_in_minute seconds = b % sec_in_minute else : days=0,hours =0 ,minutes =0 ,seconds = b print ( days, "days" , hours , "hours" , minutes , "minutes" , seconds ,"seconds" )

16th Sep 2017, 11:36 PM
Hamada Hellal
Hamada Hellal - avatar
1 Answer
+ 2
i think you should add an "and" because , if b was greater than secinday it will be greater than secinhour and same thing to secinminute so if this is true : elif b > sec_in_hour and b < sec_in_day: and also , same thing to sec_in_minute ! answer me asap you try this .
17th Sep 2017, 12:05 AM
New Coder
New Coder - avatar