Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to check if an input is a number in python

user_input = input("Enter Something:")

if user_input.isnumeric():
  print("Is a number")
else:
  print("Is not a number")
Comment

how to check if a input is an integer python

whatever = input("Pick an integer > ")
try:
	whatever_as_an_integer = int(whatever)
   	print("That was an integer.")

except ValueError:
    print("That is not an integer.")
Comment

PREVIOUS NEXT
Code Example
Python :: generate a list of random non repeated numbers python 
Python :: how to get only first record in django 
Python :: check if number is power of 2 python 
Python :: pip version command 
Python :: python add titles to subplots 
Python :: python sort list by last element 
Python :: how to install nltk 
Python :: Connecting Kaggle to Google Colab 
Python :: get current month py 
Python :: python prompt for input 
Python :: change false to true python 
Python :: display full dataframe pandas 
Python :: easiest way to position labels in tkinter 
Python :: remove all occurrences of a character in a list python 
Python :: jupyter notebook show more rows 
Python :: python count nested keys 
Python :: print specific part in bold or colours and end. 
Python :: pprint python 
Python :: jupyter read in csv 
Python :: import excel file to python 
Python :: python minute from datetime 
Python :: python import all words 
Python :: save image python 
Python :: libraries used in ANN with sklearn 
Python :: how to do key sensing in python 
Python :: python datetime now only date 
Python :: how to make otp generator in python 
Python :: csv from string python 
Python :: python add current directory to import path 
Python :: python timeit commandline example 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =