Convert the number from International system to Indian system | Function to convert a number represented in International numeric system to Indian numeric system . ; Find the length of the input string ; Removing all the separators ( , ) from the input string ; Reverse the input string ; Declaring the output string ; Process the input string ; Add a separator ( , ) after the third number ; Then add a separator ( , ) after every second number ; Reverse the output string ; Return the output string back to the main function ; Driver code
def convert ( input ) : NEW_LINE INDENT Len = len ( input ) NEW_LINE i = 0 NEW_LINE while ( i < Len ) : NEW_LINE INDENT if ( input [ i ] == " , " ) : NEW_LINE INDENT input = input [ : i ] + input [ i + 1 : ] NEW_LINE Len -= 1 NEW_LINE i -= 1 NEW_LINE DEDENT elif ( input [ i ] == " ▁ " ) : NEW_LINE INDENT input = input [ : i ] + input [ i + 1 : ] NEW_LINE Len -= 1 NEW_LINE i -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT i += 1 NEW_LINE DEDENT DEDENT input = input [ : : - 1 ] NEW_LINE output = " " NEW_LINE for i in range ( Len ) : NEW_LINE INDENT if ( i == 2 ) : NEW_LINE INDENT output += input [ i ] NEW_LINE output += " ▁ , " NEW_LINE DEDENT elif ( i > 2 and i % 2 == 0 and i + 1 < Len ) : NEW_LINE INDENT output += input [ i ] NEW_LINE output += " ▁ , " NEW_LINE DEDENT else : NEW_LINE INDENT output += input [ i ] NEW_LINE DEDENT DEDENT output = output [ : : - 1 ] NEW_LINE return output NEW_LINE DEDENT input1 = "123 , ▁ 456 , ▁ 789" NEW_LINE input2 = "90 , ▁ 050 , ▁ 000 , ▁ 000" NEW_LINE print ( convert ( input1 ) ) NEW_LINE print ( convert ( input2 ) ) NEW_LINE