Check if a given string is a comment or not | Function to check if the given string is a comment or not ; If two continuous slashes preceeds the comment ; Driver Code ; Given string ; Function call to check whether then given string is a comment or not
def isComment ( line ) : NEW_LINE INDENT if ( line [ 0 ] == ' / ' and line [ 1 ] == ' / ' and line [ 2 ] != ' / ' ) : NEW_LINE INDENT print ( " It ▁ is ▁ a ▁ single - line ▁ comment " ) NEW_LINE return NEW_LINE DEDENT if ( line [ len ( line ) - 2 ] == ' * ' and line [ len ( line ) - 1 ] == ' / ' and line [ 0 ] == ' / ' and line [ 1 ] == ' * ' ) : NEW_LINE INDENT print ( " It ▁ is ▁ a ▁ multi - line ▁ comment " ) NEW_LINE return NEW_LINE DEDENT print ( " It ▁ is ▁ not ▁ a ▁ comment " ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT line = " GeeksForGeeks ▁ GeeksForGeeks " NEW_LINE isComment ( line ) NEW_LINE DEDENT