0

I am currently learning Python --version 3.4 and I have an issue while converting seconds in dd:hh:mm:ss.

If I only convert seconds into hh:mm:ss it's working but when I try with days for example with 86400 seconds it'll give me this:

./convert.py
Enter seconds: 86400
1 d 24 h 0 m 0 s

I'm not sure if I understand why it is doing this and I've been trying to fix this issue but I can't seem to find out how to do this properly.

s = int(input("Enter the seconds: "))

d = int(s / 60 / 60 / 24 % 365)

h = int(s / 60 / 60)   

m =int(s / 60 % 60)    

sec = int(s % 60)      

print(d,"d" ,h,"h" ,m,"m" ,sec,"sec")  
Delgan
  • 18,571
  • 11
  • 90
  • 141
Antoine
  • 1
  • 2

0 Answers0