top of page

3. Input

What is Input?

The input function allows a user to insert a value into a program. It prompts the user and reads the line, converting the data into a string and returning it.

Why Input?

As programmers, you may need to interact with the users to collect data for your programs. Inputs are an easy way for programmers to do so.

How do you use Input?

Calling the input function is very similar to printing. Instead of typing out the word print, type the word input followed by any information you would want to display into the console.

input("Enter your name: ")

But what if you wanted to save the input data. How could you do that?

It is quite simple. All you need to do write out a variable and make the input function be the value you want to store inside of the variable. 

my_name = input("Enter your name: ")

Now, your variable will hold whatever input the user gives to you.

And that's all there is to Input. In the next lesson, we will start exploring everything to do with file processing.

bottom of page