What is the purpose of the end=" " argument to print?

Question:

I am an online IT student and in my Python application development class we look at a coding example. Basically the code converts the characters of a string into their ordinal values:

for ch in message:
        print(ord(ch),    end=" ")

My question is what the purpose of the end=" " part is as this is never explained in the textbook. It may not be that important, but it bothers me having a part that I do not understand. Any help is much appreciated.

Asked By: Jake Long

||

Answers:

Here is an article that explains it for you
https://www.w3schools.com/python/ref_func_print.asp

in short, it specifies what you want your print statement to end in.

ie print("Hello world", end=", stack overflow") returns Hello world, stack overflow

in python, you do not need to specify it as the default is n

so the below is fine

for ch in message:
        print(ord(ch))
Answered By: scotmanDavid
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.