Day 16: Exceptions - String to Integer

  • + 0 comments

    If anyone is trying to solve this problem in Python3. Then use this code not the pre-defined code:

    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    
    S = input().strip()
    try:
        print(int(S))
    except ValueError:
        print("Bad String")