How can I ask the user for input?

I need to ask on how do we ask the input from the user or how do we tell the user to do something maybe enter his/her name or something like that?

1 Like

Hi @byte3438351959! You do that by using raw_input. You’ll learn more about later in the course but basically to get info from the user and store it in a variable you would:

userInput = raw_input("What is your name?")

This would define a variable userInput, and set its value to whatever the user typed in the terminal.

Hope this helps!


no, in python 3, it doesn’t work… It claims a “EOFerror when reading the end of the line”

In Python 3 it was changed from the raw_input function to the input function.

name = input('What is your name?')

other than the looks, it is the same as Python 2