python - How to print formatted string in Python3? -
python - How to print formatted string in Python3? -
hey have question concerning
print ("so, you're %r old, %r tall , %r heavy.") % ( age, height, weight)
the line doesn't work in python 3.4 know how prepare this?
you need apply formatting string, not homecoming value of print()
function:
print("so, you're %r old, %r tall , %r heavy." % ( age, height, weight))
note position of )
closing parentheses. if helps understand difference, assign result of formatting operation variable first:
output = "so, you're %r old, %r tall , %r heavy." % (age, height, weight) print(output)
python string python-3.x
Comments
Post a Comment