Place a conversion that can fail in a try block. A matching except block decides what to do next. ValueError is the exception int raises for text that is not an integer.
try: count = int("three") except ValueError: count = None