A code below:
info={'Resolution':'640x360', 'DisplayResolution': '640x360', 'Display Channels':'R,G,B,A'}
for key in info:
print (key + str(info[key].rjust(45,'.')))
produces a following output:
Resolution......................................640x360
DisplayResolution......................................640x360
Display Channels......................................R,G,B,A
But I would like to get:
Resolution.............................................640x360
DisplayResolution......................................640x360
Display Channels.......................................R,G,B,A
How to achieve this?
EDITED:
Thanks everyone for your valuable input. Here is a summary of the code I put together based on your suggestions:
ROW_SIZE=0
for key, value in info.iteritems():
if not key or not value: continue
key=str(key)
value=str(value)
total=len(key)+len(value)+10
if ROW_SIZE<total: ROW_SIZE=total
result=''
if ROW_SIZE:
for key in info:
result+=(key+str(info[key]).rjust(ROW_SIZE-len(key),'.'))+'\n'
print result