How to take only Integer Input in Python

preview_player
Показать описание
You can easily take an integer only input in Python by using a recursive function which continously takes input and convert to integer and return that integer value.

Function:
def get_integer(msg = "Enter Integer: "):
try:
inp = int(input(msg))
except ValueError:
print("Invalid Input, enter an integer...")
inp = get_integer(msg)
return inp

This Program Code:-

All Python Codes:-

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Subscribe to us for more videos!!!

Music: Jarico - Island

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Like And Subscribe our Channel.......
Рекомендации по теме
Комментарии
Автор

Great video, this function is very simple yet powerful.

sicblade