10 - Taking User Input

๐Ÿงถ Tags:: #Python_Basics
Up:: 11 - Strings
Down:: 09 - Typecasting in Python
๐Ÿ—ƒ Resources:: Playlist
2023-12-09 - 20:48

In python, we can take user input directly by using input() function.This input function gives a return value as string/character hence we have to pass that into a variable

Syntax:

variable=input()

But input function returns the value as string. Hence we have to typecast them whenever required to another datatype.

Example:

variable=int(input())
variable=float(input())

We can also display a text using input function. This will make input() function take user input and display a message as well

Example:

a=input("Enter the name: ")
print(a)

Output:

Enter the name: Harry
Harry