You are viewing a single comment's thread. Return to all comments →
For JS this worked:
function main() { const S = readLine(); try { const num = JSON.parse(S); console.log(num); } catch (e) { console.log("Bad String"); } }
But for Python I get: Error reading result file.You should use exception handling concepts.
I tried this:
S = input() try: num=int(S) print(num) except ValueError: print("Bad String")
and this:
S = input() try: num=int(S) print(num) except: raise Exception("Bad String")
None of these worked.
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Day 16: Exceptions - String to Integer
You are viewing a single comment's thread. Return to all comments →
For JS this worked:
But for Python I get: Error reading result file.You should use exception handling concepts.
I tried this:
and this:
None of these worked.