Python input() FunctionPython Functions


The input() function allows the user to input a string as prompt.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

a = input("input:")
print("the value of a is:  ", a)

b = input("input:")
print("the value of b is:  ", b)

Output:

input:2020
the value of a is:   2020
input:Notre Dame de Paris
the value of b is:   Notre Dame de Paris

Syntax

input([info])

Parameters

Name Description
info A String representing a default message before the input.

Return Value

It returns a string.

© 2021 Programtips.org, all rights reserved. Privacy Policy | Contact Us