Skip to content

Latest commit

 

History

History
48 lines (26 loc) · 685 Bytes

Convert_a_String_to_a_Number.md

File metadata and controls

48 lines (26 loc) · 685 Bytes

CodeWars Python Solutions


Convert a String to a Number!

We need a function that can transform a string into a number. What ways of achieving this do you know?

Note: Don't worry, all inputs will be strings, and every string is a perfectly valid representation of an integral number.

Examples

stringToNumber("1234") == 1234
stringToNumber("605" ) == 605
stringToNumber("1405") == 1405
stringToNumber("-7"  ) == -7

Given Code

def string_to_number(s):
    pass

Solution

def string_to_number(s):
    return int(s)

See on CodeWars.com