Snake case of a given sentence | Function to replace spaces and convert into snake case ; Converting space to underscor ; If not space , convert into lower character ; Driver program ; Calling function
def convert ( string ) : NEW_LINE INDENT n = len ( string ) ; NEW_LINE string = list ( string ) ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( string [ i ] == ' ▁ ' ) : NEW_LINE INDENT string [ i ] = ' _ ' ; NEW_LINE DEDENT else : NEW_LINE INDENT string [ i ] = string [ i ] . lower ( ) ; NEW_LINE DEDENT DEDENT string = " " . join ( string ) NEW_LINE print ( string ) ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT string = " I ▁ got ▁ intern ▁ at ▁ geeksforgeeks " ; NEW_LINE convert ( string ) ; NEW_LINE DEDENT