IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

print

print[*Ts: Writable](*values: *Ts.values, *, sep: StringSlice[StaticConstantOrigin] = StringSlice(" "), end: StringSlice[StaticConstantOrigin] = StringSlice("\n"), flush: Bool = False, var file: FileDescriptor = stdout)

Prints elements to the text stream. Each element is separated by sep and followed by end.

This function accepts any number of values, but their types must implement the Writable trait. Most built-in types (like Int, Float64, Bool, String) implement the Writable trait.

For string formatting, use the format() function.

Examples:

print("Hello, World!") # Hello, World!

print("The answer is", 42) # The answer is 42

print("{} is {}".format("Mojo", "🔥")) # Mojo is 🔥

Parameters:

  • ​*Ts (Writable): The elements types.

Args: