python - How do I print a function in a string? -
so trying simple calculation using python 2.7 code follows:
print 'in schmooland 9.33356564 times heavier on earth.\n' weight = float(raw_input('how weigh on earth in pounds?\n')) print 'in schmooland weigh' print weight * 9.3356564 print 'in pounds'
the output looks though
how weigh on earth in pounds? 235423423 in schmooland weigh 2197832185.64 in pounds
how print result of weight calculation on same line string print this
in schmooland weigh 2197832185.64 in pounds
i'm total n00b - help!
add comma end of each print line avoid implicit newline:
print 'in schmooland weigh', print weight * 9.3356564, print 'in pounds',
from print
documentation:
a '\n' character written @ end, unless print statement ends comma.
Comments
Post a Comment