[Solved] Python text formatting


Use string formatting:

In [48]: def solve(a,b):
    a,b=str(a),str(b)
    spaces=len(a.split())-1
    return "{0} {1} {2}".format(a,"."*(68-len(a)-len(b)-spaces),b)
   ....: 

In [49]: print solve(a,b);print solve(p,q)
Hello .......................................................... False
Python rocks ................................................... True

5

solved Python text formatting