Tuesday, 15 February 2011

Print multiple lines with variables in a single print() statement in Python -



Print multiple lines with variables in a single print() statement in Python -

is possible (using python 3):

le = "\n" var1 = 2 var2 = 5 print("information"+le "-----------"+le "variable1: {}".format(var1)+le "variable2: {}".format(var2)+le )

yes. take @ docs.

general example:

var1 = 2 var2 = 5 print("information", "------------", "variable1: {}".format(var1), "variable2: {}".format(var2), sep='\n')

python python-3.x

No comments:

Post a Comment