Convert string to integer without using any in | Function to convert string to integer without using functions ; Initialize a variable ; Iterate till length of the string ; Subtract 48 from the current digit ; Print the answer ; Driver code ; Given string of number ; Function Call
def convert ( s ) : NEW_LINE INDENT num = 0 NEW_LINE n = len ( s ) NEW_LINE for i in s : NEW_LINE INDENT num = num * 10 + ( ord ( i ) - 48 ) NEW_LINE DEDENT print ( num ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = "123" NEW_LINE convert ( s ) NEW_LINE DEDENT