[email protected] wrote:
> Thank you for the suggestions.
>
> Some little reading gave the idea and it works well too. :)
>
> Here is the code:
> fileIN = open("test.txt")
> count = 0
> for line in fileIN:
> data= line
>
> if '####' in data:
> count = 4
> elif '###' in data:
> count = 3
> elif '##' in data:
> count = 2
> elif '#' in data:
> count = 1
> elif data.find('#') == -1:
> count = 0
>
> if (count == 0):
> print data + '\nlooks like a code line...\n'
> elif(count== 4):
> print data + '\ninvalid line!\n'
> elif count>=1:
> for i in range(0, count):
> print data
What happens when your input file has a line like:
This is a ## fake line
You might want to check out the strip and startswith methods of strings.
--RDM
--
http://mail.python.org/mailman/listinfo/python-list