def time_f(t_secs): try: val = int(t_secs) except ValueError: return "!!!ERROR: ARGUMENT NOT AN INTEGER!!!" pos = abs( int(t_secs) ) day = pos / (3600*24) rem = pos % (3600*24) hour = rem / 3600 rem = rem % 3600 mins = rem / 60 secs = rem % 60 res = '%03d:%02d:%02d:%02d' % (day, hour, mins, secs) if int(t_secs) < 0: res = "-%s" % res return res prompt = time_f( raw_input("Enter a length of time in seconds: ") ) print "Time is %s." % prompt
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question