Search code snippets, questions, articles... Chrome Extension

Use separator in print() method of python

While printing values using the print() method in python we can pass a separator which will be added between values passed inside print() methid.
first_name = "Rick"
last_name = "Grimes"
print("My", "name", "is", first_name, last_name, sep=" ")
# -> My name is Rick Grimes

print("My", "name", "is", first_name, last_name, sep=":")
# -> My:name:is:Rick:Grimes
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

In the code snippet, we are printing different values and passing separator using sep="" syntax. In the first example, we are printing values with a space separator and in the second example we are using separator ":".

Was this helpful?
0 Comments
Join Devsheet Ask a Question