bhylu.com

Advertisements

Print Text

print makes a value visible while you learn or debug. It can accept several arguments, so you do not need to convert every number to text manually.

Understand the idea

By default, print separates arguments with spaces and ends with a newline. The sep and end keyword arguments change those choices. Console output is different from returning a value from a function; later callers cannot use a printed message as the function's calculated result.

Where to try it

Open this example with Try in playground. The code loads as editable text and does not run until you select Run. The first run downloads Python. Each run starts fresh; temporary files created by a script are not files on your PC.

A worked example

Python

print("Mira", "Dev", sep=", ")
print("Ready", end=" - ")
print("go")

Read the result

The first line is Mira, Dev. The next is Ready - go because the second call does not end with a newline.

Try one change

Print three workshop names separated by a slash, then print a completion message on its own line.