How to Get Input from User in Python

Today we’re going to see how to get input from user in Python.

Table of Contents

  1. Input String
  2. Input Integer
  3. Input Float

Input String

We use input() function in Python to get user input.
var = input("Enter any string: ")

Input Integer

We can take only integer input using int(input()).

var = int(input("Enter an Integer: "))

Input Float

We can take only integer input using float(input()).

var = float(input("Enter a float value: "))
That’s it. Thanks for reading. ?

Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.