0

What do I write in print to make this thing display seconds in hh:mm:ss format? Sorry if Im saying some BS since I'm really new to coding


x = int(input())
s = x
m = x//60
h = x//3600
print(

1 Answers1

0
x = int(input())
s = x % 60
m = (x//60) % 60
h = x//3600
print( "%02d:%02d:%02d" % (h,m,s) )

Depending on what you're doing, it might be better to use the datetime module for this.

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
  • Saving some work (at least in theory), you could do `s = int(input())`, `m, s = divmod(s, 60)`, `h, m = divmod(m, 60)`. That said, the duplicate has even more direct solutions. – ShadowRanger Mar 10 '22 at 20:49