import re
string = "aaaaa, bbb ,cccc, hhhh, fff,t";
def repl(match):
return match.group(1).ljust(10)
rx = r'(\w+)(\s*,|$)'
string = re.sub(rx, repl, string)
print string
aW1wb3J0IHJlCgpzdHJpbmcgPSAiYWFhYWEsIGJiYiAsY2NjYywgaGhoaCwgZmZmLHQiOwoKZGVmIHJlcGwobWF0Y2gpOgoJcmV0dXJuIG1hdGNoLmdyb3VwKDEpLmxqdXN0KDEwKQoKcnggPSByJyhcdyspKFxzKix8JCknCnN0cmluZyA9IHJlLnN1YihyeCwgcmVwbCwgc3RyaW5nKQpwcmludCBzdHJpbmc=