cooldog cooldog - 1 year ago 197
Python Question

Python insert tab in string

I just began learning Python. I'm not sure how to insert tab in string.
For instance, how can i insert tab to the right of "World" in the strings below:

example = ' Hello World'

Everytime I use Tab after "World" a drop down menu appears, how can I avoid that? thanks!
I tried using
, but then
gives the result of
Hello World\t
, instead of
Hello World

Thanks for the answers. I used
example = ' Hello World\t'
, it works.
gives the result:
Hello World
, without

Answer Source

The dropdown error is because of the editor you are using. Just try using plain notepad++. It's working! I tried.

print "Hello World\t",
print "hi"

Just to make sure that there is tab after the first print, print one more statement. you will come to visual it. Make sure to use comma ',' after print to stay in the same line if you are using python 2.7. Else use end="" for python 3+ to stay in the same line.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download