What is input function. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is input function.

just give an easy example for it

14th Dec 2017, 7:11 AM
Siddharth Bisht
Siddharth Bisht - avatar
1 Answer
+ 2
input() gets input from the user and returns it as a string (str) type. You can pass in a string as a prompt to the user. i = input("What is your name? ") print("Hello", i) Remember that if you are expecting something like an integer input from the user that you'll need to convert it to that type before you perform mathematical calculations with it. age = int(input("How old are you? ")) # convert the input to an integer using int() current_year = 2017 print("Were you born in", current_year - age)
14th Dec 2017, 7:24 AM
ChaoticDawg
ChaoticDawg - avatar