Saturday, 24 December 2011

pythonchallenge3

http://www.pythonchallenge.com/pc/def/equality.html

the first ch is small
next three chs is bigger
comiing a smaill one
three bigger one go after
finall there has small one




data=open('c:/Python27/level3.txt')
smallLetter=""
lines=data.readlines()
print 'lines:',len(lines)
i=0
while i < len(lines):
    #print 'i:',i,'len:',len(lines[i])
    a=0
    while a+9< len(lines[i]):
        #print 'lines[',i,'][',a,']:',lines[i][a]
        if lines[i][a].islower() and lines[i][a+1:a+4].isupper()and lines[i][a+4].islower()and lines[i][a+5:a+8].isupper()and lines[i][a+8].islower():
            smallLetter=smallLetter+lines[i][a+4]
            print 'i',i,'a:',a+4
        a =a+1
       
    i=i+1
print 'smallLetter:',smallLetter,len(smallLetter)




============
 b= re.search(r'[^A-Z][A-Z][A-Z][A-Z][a-z][A-Z][A-Z][A-Z][^A-Z]',testline,re.M)