'Convert seconds to hh:mm:ss Python [duplicate]

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(



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tim Roberts