Note: This kata is inspired by [Convert a Number to a String!](http://www.codewars.com/kata/convert-a-number-to-a-string/). Try that one too.

## Description

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

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

Difficulty: introductory

Starter code:

def string_to_number(s):
	

Solutions:
def string_to_number(s):
    return int(s)

string_to_number = int

string_to_number = lambda n: int(n)

string_to_number=lambda s:int(s)

def string_to_number(s):
    # ... your code here
    s = int(s)
    return s

def string_to_number(s):
    i = int(s)
    return i

def string_to_number(s):
    # ... your code here!
    number = int(s)
    return number

def string_to_number(s):
    result = 0    #Variable to hold running total of integer to return
    place = 1    #Decimal value of place currently being calculated
    i = len(s) - 1
    while i >= 0:
        digit = s[i]    #The piece of the string being transferred
        if digit == '1':
            result += place
        elif digit == '2':
            result += (2*place)
        elif digit == '3':
            result += (3*place)
        elif digit == '4':
            result += (4*place)
        elif digit == '5':
            result += (5*place)
        elif digit == '6':
            result += (6*place)
        elif digit == '7':
            result += (7*place)
        elif digit == '8':
            result += (8*place)
        elif digit == '9':
            result += (9*place)
        elif digit == '-':
            result = -result
        place *= 10
        i -= 1
        
    return result

string_to_number = eval

#krishp
def string_to_number(s):
    return float(str(float(str(int(s)))))

from re import match as m

string_to_number = lambda s: eval(s) if m(r'^[-+]?\d+$', s) else None

def string_to_number(s):
    # ... your code here
    num = 0
    flag = False
    if s[0] == '-':
        flag = True
    for i in range(len(s)):
        if flag and i == 0: 
            continue
        else:
            num += int(s[i])
            if i != len(s) - 1:
                num *= 10
    return num if not flag else -1* num


def string_to_number(s):
    negative = False
    if s[0] == '-':
        s = s[1:]
        negative = True
    if s.isdigit():
        return -int(s) if negative == True else int(s)
            


def string_to_number(s):
    new_list=list(s)
    flag = True
    if new_list[0] == '-':
        new_list.pop(0)
        flag = False
    
    test_list=['0','1','2','3','4','5','6','7','8','9']
    
    for i in range(0,len(new_list)):
        if new_list[i] not in test_list:
            for j in range(i,len(new_list)):
                new_list.pop(i)
            break
    
    num_list=new_list[-1::-1]
    
    total=0
    for i in range(0,len(num_list)):
        num=int(num_list[i])
        total += num*10**i
    total = (total if(flag) else -1*total)
    
    return total

import pandas as pd
def string_to_number(s):
    # ... your code here
    number = int(s)
    return number

def string_to_number(s):
    return eval(s)

def string_to_number(s):
    ch = 0
    for i in s:
        if i.isdigit():
            ch = ch * 10 + int(i)
    return ch if s[0] != '-' else -ch

def string_to_number(s):
    res = 0
    neg = 1
    print(s) 
    l = len(s) -1
    for i in s:
        if i == "-":
            neg = -1
            l = l -1
        else:
            res += int(i) * (10**l)
            l = l-1
        print (res) 
    return res * neg 

def string_to_number(s):
    # ... your code here
    ans = 0
    counter = 1
    for i in s[::-1]:
        if i == '-':
            ans*=-1
        else:
            ans+= int(i)*counter
            counter*=10
    return ans

def string_to_number(s):
    # ... your code here
    try:
        return int(s)
    except:
        pass

def string_to_number(s):
    a=int(s)
    return a
string_to_number("1234")

def string_to_number(s):
    if s == str(s):
        return int(s)
    else:
        return 'Error'

def string_to_number(s):
    return int(s)
string_to_number("23")

def string_to_number(s:str)->int:
  result:int = int(s)
  return result  
    # ... your code here


def string_to_number(s):
    x = 0
    yygq = 1 if s[0] == "-" else 0
    for i in range(yygq,len(s)):
        x += (ord(s[i])-48)*10**(len(s)-i-1)
    return -x if yygq == 1 else x

def string_to_number(s):
    y=int(s)
    return y
string_to_number('50')

def string_to_number(s):
    newInt = int(s)
    return newInt

string_to_number = lambda s: int(s)

"""Convert a String to a Number!"""

def string_to_number(num):
    return int(num)

#Goal:
# Write a program that takes a string of numbers as input and returns an integer.
#General Strategy:
# Reformat the string integer into an integer.

def string_to_number(s):
    # Reformat s into an int
    return int(s)


def string_to_number(s):
    
    result = 0
    for i in range(len(s)):
        result = result * 10 + int(s[i]) if s[i] in '0123456789' else result
            
    return -result if s[0] == '-' else result

def string_to_number(s):
   return int(s)
print(string_to_number('605'))

def string_to_number(s):
    nummer = int(s)
    return(nummer)

import string
a=string


def string_to_number(a):
        int(a)
        return int(a)
    
if a==str(a):
 string_to_number(a)

def string_to_number(s):
    # ... your code here
    
    try:
        return(int(s))
        
    except:
        print("not a number.")

def string_to_number(s):
    return int(s) # -_-

def string_to_number(s):
    # ... your code here
    nums= int(s)
    
    return nums

print(string_to_number("1333"))

def string_to_number(s):
    return int(s, base=10)

def string_to_number(s):
    vlo = int(s)
    return vlo
    # ... your code here


def string_to_number(s):
    s=int(s)
    return(s)
s='234'
print(string_to_number(s))

def string_to_number(s):
    if '-' not in s:
        return int(s)
    else:
        return float(s)

def string_to_number(s):
    int_number = int(s)
    return int_number


def string_to_number(s):
    if s[0]=="-":
        return -1*int(s[1:])
    return int(s)

# INVINCIBLE WARRIORS --- PARZIVAL

def string_to_number(s):
    return int(s)

def string_to_number(s):
    # Return a string to a integer
    return int(s)

def string_to_number(n):
    return int(n)

def string_to_number(s):
    # ... your code her
    return int(s)

def string_to_number(s):
    newStr = int(s, 10)
    
    return newStr

def string_to_number(s):
    return int(s)
  
print(string_to_number("34"))

def string_to_number(s):
    # ... your code here
    x = eval(s)
    return x

def string_to_number(string):
    string = int(string)
    return string

def string_to_number(s):
    string = str(s)
    jo = "".join(string)
    num = int(jo)
    return num

def string_to_number(s):
    s = int(s)

    return int(s)


def string_to_number(s):
    if s[0] != '-':
        d = 1
    else:
        d = -1
        s = s[1:]
    num = 0
    for c in range(len(s)-1, -1, -1):
            num += int(s[c])*d
            d *= 10
    return num

def string_to_number(s):
    if s == str(s):
        return int(s)
    return str(s)

def string_to_number(s):
    return int(s)

string_to_number("6")


def string_to_number(s):
    print((int(s)))
    return int(s)


def string_to_number(s):
    num_string = int(s)
    return num_string
    
    # ... your code here


string_to_number = lambda a : int(a)

def string_to_number(a):
    return float(a)

def string_to_number(s):
    if s != int:
        num = int(s)
    return num

def string_to_number(s):
    soluzione = int(s)
    return soluzione 

def string_to_number(s):
    a = s
    n = int(a)
    return n

def string_to_number(s):
    wynik = int(s)
    return wynik

def string_to_number(s):
    value = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
    result = 0
    pos_or_neg = 1
    for i in s:
        if i == ("-"):
            pos_or_neg = -1
        if i in value:
          result = result * 10 + value[i]
        
    return result * pos_or_neg


def string_to_number(s):
    if s.isdigit():
        return int(s)
    else:
        return -int(s[1:])

def string_to_number(s):
    if s[0]=="-":
        mul=-1
        i=1
    else:
        mul=1
        i=0
    ans=0
    while i<len(s):
        x=s[i]
        x=ord(x)-ord('0')
        ans=(ans*10)+x
        i=i+1
    return ans*mul

def string_to_number(s):
    str("")
    return int(s)
    # ... your code here


def string_to_number(s):
    return int(s)
print (string_to_number)

def string_to_number(s):
    # ... your code here
    numb=int(s)
    return numb

def string_to_number(s):
    try:
        return int(s)
    except:
        Gary

def string_to_number(s):
    convert_number=int(s)
    return convert_number


def string_to_number(s):
    num = float(s)
    return num


def string_to_number(s):
    return int(s)
    
 # from Russia with love


def string_to_number(s):
    if s is None:
       return None
    return int(s)
    
    # ... your code here


def string_to_number(s):
    # ... your code here
    return (int(s))
    if s[0]=="-":
        for i,value in enumerate(s[1:]):
               number+=int(value)**10^(len(s)-i-1)
        number=-1*number
    
    else:

    
        for i,value in enumerate(s):
          print(i,value)
          number=number+int(value)*10**(len(s)-i-1)
          print(number,10^(len(s)-i-1))
    return(number)

def string_to_number(s):
    # ... your code here
    try:
        int(s)
        return int(s)
    except e:
        print("not an integer")
        pass
        


def string_to_number(s):
    # ... your code here
    #int() takes a position argument x
    #x can be a string or some other type
    #returns x as a string
    return int(s)

def string_to_number(s):
    try:
        return int(s)
    except ValueError:
        print("Input data cannot be represented as a number")
        return None

def string_to_number(s):
    #s = input("Enter a string")
    return int(s)

def string_to_number(s):
    # Ok, let's get real.  Converting from a string of numbers to an integer is easy.
    # here's the one line that solves this:
    #     return int(s)
    #
    # So let's have some fun...
    # Let's convert the number to binary first!
    binary = bin(int(s))
    print (s + ' in binary: ' + binary)
    # Then hexadecimal
    hexa = hex(int(binary,2))  # yeah, cheating by turning binary to decimal, then to hex
    print(binary + ' in hex: ' + hexa)
    # Wonder what happens if we reverse the characters in the hex string?
    remove0x = hexa.replace('0x','')
    reversed = '0x' + remove0x[::-1]
    print('Reversed: ' + reversed)
    # Well that was pointless!
    # Hmm... take the ascii code of each character in hexa (other than '0x', multiply it by
    # 10 to the power of (length of the string - index of the character) ?
    multiplied = ''
    for i in range(len(remove0x)):
        multiplied += chr(ord(remove0x[i])*(10*(len(remove0x)-i)))
    print('Multiplied: ' + multiplied)
    #
    # We're getting nowhere fast.
    see = 0
    for i in multiplied:
        see += ord(i)
    print('Ascii added: ' + str(see))
    # Nope.
    rereversed = '0x' + reversed.replace('0x','')[::-1]
    print(rereversed + ' is ' + reversed + ' reversed again.')
    if '-' in rereversed:
        rereversed = '-' + rereversed.replace('-','')
    # If the number is negative, let's get the negative sign in the right place
    print('If we change that to integer and return it...  Hmm!')
    #
    # Could it be that simple???
    return int(rereversed,16)

def string_to_number(s):
    number = 0
    if s[0] == '-':
        for n in s[1:]:
            number = number*10 + (ord(n) - ord('0'))
        return -number
        
    else:
        for n in s:
            number = number*10 + (ord(n) - ord('0'))
        return number

def string_to_number(s):
    if s[0] == '-':
        startDigitIdx = 1
    else:
        startDigitIdx = 0
        
    number = 0;
    
    for n in s[startDigitIdx:]:
        number = number*10 + (ord(n) - ord('0'))
        
    if s[0] == '-':
        return -number
    else:
        return number



def string_to_number(s):
    for  number in s:
        if number in '+-1234567890':
            return int(s)

def string_to_number(s):
    transformar = int(s)
    return transformar
    
string_to_number("1234")

def string_to_number(s):
    str_int=int(s)
    return str_int
    # ... your code here


def string_to_number(s):
    return int(s) if '.' not in s else float(s)

def string_to_number(s):
    new_number = int(s)
    return new_number

def string_to_number(s):
    neg = s[0] == '-'
    num = 0
    i = 0
    if neg:
        i = 1
    while i < len(s):
        num = num * 10 + (ord(s[i]) - ord('0'))
        i += 1
    return (-1 if neg else 1) * num

def string_to_number(s):
    s = int(s)
    return s
    
string_to_number

def string_to_number(s):
    v = int(s)
    return (v)

def string_to_number(s):
  #test_list = [int(s) for s in string_to_number]
 # return(test_list)
 return int(s)

def string_to_number(s):
    a = int(s)
    print(a)
    return(a)
string_to_number('1234')

def string_to_number(s):
    return int(''.join(list(s)))

def string_to_number(s):
    # ... your code here
    #s= ''
    return int(s)
    #s==nm


def string_to_number(s):
    # ... our code here
    return int(s)

def string_to_number(s):
    x = int(s)
    return x
    
print("1234")

def string_to_number(s):
        return int(s)
        
        
string_to_number("555")

def string_to_number(n):
    num=int(n)
    return num;