Skip to content

Python code snippet – How to say that an input needs to be a number ?

try:
   val = int(userInput)
except ValueError:
   print("That's not an int!")
See also  How to add lists to lists in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.