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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -