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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -