Day 16: Exceptions - String to Integer

  • + 0 comments

    If you get this in your Python 3 code test: Compiler Message: Error reading result file.You should use exception handling concepts

    then remove this line and test again:

    if name == "__main__":
    

    I also stucked in loop to testmy code everywhere, even GPT says my code is correct. I go through discussions and saw same probloem with a guy and tested without that block, I was shocked, my code is now works well and ready for submission.

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