Python Forum
Converting a remainder to int to str
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting a remainder to int to str
#1
Hi,
I'm converting seconds to HH:MM:SS and having a hard time converting a remainder (seconds) to an integer to a string Confused .
I found this code online and it looks good but I cannot join it as a string HH:MM:SS because I cannot convert a remainder (seconds) ->int ->string.
Here is the code:
sec = 50007
sec_value = int(sec % (24 * 3600))
hour_value = str(int(sec_value // 3600))
sec_value %= (int(3600))
min = str(int(sec_value // 60))
sec_value %= 60

print("Converted hours:  ",hour_value)
print("Converted minutes:",min)
print("Converted seconds:",sec_value)
print ("Cannot add Seconds. Only hours and minutes :   "+hour_value+":"+min+":"+"Seconds here")
Thank you!
Reply


Messages In This Thread
Converting a remainder to int to str - by tester_V - Oct-27-2020, 07:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Could not parse the remainder: '=' from '=' Saurabh 3 14,447 Feb-20-2019, 11:18 AM
Last Post: buran
  remainder operator % noweare 3 2,817 Feb-14-2019, 01:50 AM
Last Post: noweare

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020