python - Get two strings of text on the same line? -


and sorry terrible title! had no idea write, without making tile 500 words long.

let's have

print 'hi!' print 'how you?' 

is there way can same line? "hi! how you?"

here codes using:

choice = raw_input('>: ') if choice=='1':     menu1() else:     print '' +choice     print 'is not recognized commando.' 

the other code have is:

from colorama import fore, back, style print print 'now chatting tom' time.sleep(2) print print print(fore.red + 'tom >: ') + print(fore.green + 'test') 

of course didn't work. wanted test.

is there way can these 2 string same line?

thank much!

edit:

thank everyone! know basic parts of python, have no idea how ignore ,

anyway. reason spaces. want write [12:41:39] (time). in code, looks this:

print(fore.yellow + '['), print strftime("%h:%m:%s"), print ']          ', 

and output [ 12:41:39 ]

i have no idea what's wrong here. hope here explain me! thank you!

in python 2.x, print statement, add trailing comma:

print 'hi!',  # no newline printed 

in python 3.x, print() ordinary function instead of statement, pass empty string end keyword parameter:

print('hi!', end='') 

if use from __future__ import print_function in python 2.x code forwards compatibility, you'll need use function version instead of statement version.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -