Here is the code I've tried,
from re import *
commentStart = compile('/\*')
commentEnd = compile('\*/')
singleComment = compile('//')
quotes = compile('".*"')
def readComment(line):
while(line):
if(commentEnd.match(line)):
return
line = input()
line=input()
while(line):
if(quotes.match(line)):
print(line)
line = input()
continue
elif(commentStart.match(line)):
readComment(line)
line=input()
continue
elif(singleComment.match(line)):
line=input()
continue
else:
print(line)
line=input()
I'm able to remove the single line comments but i have problem with the multi line comments.
Sample input:
abcd
//blah
efg
/*blah
blah
blah*/
hij
My Output:
abcd
efg
Expected Output:
abcd
efg
hij
Please point out where I've made mistake. Thankyou.