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"); } }
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
Day 16: Exceptions - String to Integer
You are viewing a single comment's thread. Return to all comments →
For JS this worked:
` None of these worked.