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[*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:
- ​*values (
*Ts.values): The elements to print. - ​sep (
StringSlice[StaticConstantOrigin]): The separator used between elements. - ​end (
StringSlice[StaticConstantOrigin]): The String to write after printing the elements. - ​flush (
Bool): If set to true, then the stream is forcibly flushed. - ​file (
FileDescriptor): The output stream.