Task 12 time difference problem with brackets

Back to General discussions forum

magnusnepridaval     2019-05-30 15:23:18

The program counts correctly. I do not understand how to put brackets correctly

magnusnepridaval     2019-05-30 15:24:06
out1.extend(['(',str(d3),str(h3),str(m3),str(s3),')'])
print(' '.join(out1))
Rodion (admin)     2019-06-02 07:13:20
User avatar

Please sorry for delay, I didn't at once understand the question.

I see now you have problem solved already by using something like

print('('+str(d3),str(h3),str(m3),str(s3)+') ')

That's very good!

I can only add that sometimes the string template can be used in such cases:

result = "(%s %s %s %s)" % (d3, h3, m3, s3)

You see, we form template just as we want result string to look like - but put %s in places where values should be. Then we pass values in a tuple, after % operator. If there is only one value, it can be passed without tuple.

magnusnepridaval     2019-06-08 14:54:55

Thanks for the help. Your template is more effective

Please login and solve 5 problems to be able to post at forum