Skip to content

Latest commit

 

History

History
55 lines (33 loc) · 1019 Bytes

README.md

File metadata and controls

55 lines (33 loc) · 1019 Bytes

30 Days of Code - Day 16

To view solutions, see the file exceptions-str-to-int.py in your text editor.

Day 16: Exceptions - String to Integer

Task:

Read a string, S, and print its integer value; if S cannot be converted to an integer, print Bad String.

Note: You must use the String-to-Integer and exception handling constructs built into your submission language. If you attempt to use loops/conditional statements, you will get a 0 score.

Input Format

A single string, S.

Constraints

  • 1 <= |S| <= 6, where |S| is the length of string S.
  • S is composed of either lowercase letters (a - z) or decimal digits (0 - 9).

Output Format

Print the parsed integer value of S, or Bad String if S cannot be converted to an integer.

Sample Input

3

Sample Output

3

Sample Input

za

Sample Output

Bad String

Solution:

In exceptions-str-to-int.py.

Return to navigation list