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).
input
input(prompt: String = "") -> String
Reads a line of input from the user.
Reads a line from standard input, converts it to a string, and returns that string. If the prompt argument is present, it is written to standard output without a trailing newline.
Examples:
name = input("Enter your name: ")
print("Hello", name)
If the user enters "Mojo" it prints "Hello Mojo".
Args:
- prompt (
String): An optional string to be printed before reading input.
Returns:
String: A string containing the line read from the user input.
Raises:
If the operation fails.