We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 16: Exceptions - String to Integer
Day 16: Exceptions - String to Integer
Sort by
recency
|
1008 Discussions
|
Please Login in order to post a comment
I had to remove the "if name == 'main':"
!/bin/python3
import math import os import random import re import sys if name == 'main': try: S = input() result = int(S) print(result) except ValueError: print("Bad String") except Exception: print("Bad String")
I've try many times. The compiler / Interperter is facing an issue. Please review it!
this is java 7 simple code import java.io.; import java.util.;
public class Solution { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
}
S = input().strip() try: print(int(S)) except ValueError: print("Bad String")