Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

print in Python 3

  • print
  • end
  • sep
print("hello")
print("world")
print("Foo", "Bar")
hello
world
Foo Bar
print("hello", end=" ")
print("world")
print("Foo", "Bar")

print("hello", end="")
print("world")


print("hello", end="-")
print("world")
hello world
Foo Bar
helloworld
hello-world

end will set the character added at the end of each print statement.

print("hello", end="")
print("world")

print("Foo", "Bar", sep="")
print("END")
helloworld
FooBar
END

sep will set the character separating values.