Python input() function
The input() function in Python reads a line from input and converts it to a string (stripping a trailing newline).
Syntax
1 2 3 |
input([prompt]) |
Parameter
prompt: This function represents a string, depicting a default message before the input.
Return
This function returns the string value if theĀ promptĀ argument is present and it is written to standard output without a trailing newline.
Example 1
1 2 3 4 5 6 |
# Python program explaining # the input() function str1 = input("Enter your name:") print("Hello, " + str1) |
Output
1 2 3 4 |
Enter your name:reema Hello, reema |