Ad space (banner)
๐ŸŸฃJulia Lessons
Lesson 58 / 68

Reading a value from standard input

This lesson covers reading standard input with Julia's readline, with the aim of writing programs that handle input from a user.

readline() reads one line of input from the keyboard. Use it when a command-line tool needs the user to type something.

The sample code prompts without a line break using print("Enter your name: "), receives the typed string into name with readline(), and uses it in a greeting.

A common early stumble is the difference between print() and println(). Not knowing that print() does not add a line break can leave the input prompt in an odd place.

In professional work, using an input value without validating it leads to unexpected errors, so pairing it with a check is the safe approach.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Julia directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)