Problem 100326 · easy · Phase 01 Prerequisites & Setup

Add Two Numeric Strings

functions · type conversion · strings · arithmetic

Two numbers arrive as text (for example from a form on a web page). Write add_strings(a, b) that returns their sum as an integer.

Examples

Input:  a = "12", b = "30"
Output: 42
Input:  a = "-5", b = "5"
Output: 0

Constraints

  • Each string holds a valid integer between -10**12 and 10**12, possibly with a leading -.

Goals

  • Recognise that '12' + '30' is not 42
  • Convert strings to int before doing arithmetic
Starting Python…