I'm looking for a way to divide a number which represents seconds passed (e.g. 11000) by 3600 to make it full hour and create a list like this:
['3600','3600','3600','200']
I know that this task is quite simple with basic math operations but I'm curious if there is more 'pythonic' way to achieve this.
CodePudding user response:
I think, its quite simple in the pythonic way. Try this.
elapsed = 11000
split_list = ["3600"] * (elapsed // 3600) [str(elapsed % 3600)]
In simple words, populate the fixed list and then append the difference.
CodePudding user response:
You may try this :-
num = 11000//3600
times = []
for i in range(num):
times. append("3600")
times. append(str(11000%3600))
print(times)