Skip to content

Latest commit

 

History

History
33 lines (20 loc) · 623 Bytes

How to get input from user in python.md

File metadata and controls

33 lines (20 loc) · 623 Bytes

Python Input()

Function to save a user's response.

Syntax

input(prompt)

Function return

The input function returns the string written by the user.

Function parameter

The function can receive a prompt parameter to write a message before the input

Examples:

  1. Getting the user's name:
name = input('What is your name? ')
  1. Getting the user's age:
age = int(input('How old are you? '))

Remember that the response of the input is aways a string, so to make the age a integer number we have to change the type from string to int by using the function int()