input([prompt])
The input function returns the value of prompt -if it has been included as an argument to the function-, reads a line from the standard input -the keyboard, by default-, converts it to a text string and returns it as result of the function.
- prompt: Text to be displayed before the text input field.
The input function returns a text string.
In this example we assign the text entered by the user to the texto variable:
texto = input("Introduce un texto:")
print("Has introducido el texto {}".format(texto))
Once we enter some text and press the Enter key, the execution of the cell continues, which, in this case, prints the entered text:
We can convert the input to another type. In this second example we are inviting the user to enter an integer, and the input is converted to that type (in this example we are not expecting the user to enter something else, which would raise an error):
numero = int(input("Introduce un número entero:"))
print("Has introducido el número {}".format(numero))
print(type(numero))