Help required to read and print lines based on the type of first character

Paul Rubin http
Thu Mar 5 07:26:36 CET 2009


Abhinayaraj.Raju at Emulex.Com writes:
> 	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

import re
max_sharps = reduce(max, map(len, re.findall('#+', data)), 0)
max_sharps = min(max_sharps, 4)



More information about the Python-list mailing list