Truel=""
count = 0
finle_touch=False #true after it find the first 3 upperletter
# check if there is 1 lower letter after three upper letter
def one_lower(i):
count=0
if i == i.lower:
finle_touch=True
Truel=i
# check for 3 upper letter
def three_upper(s):
for i in s:
if count == 3:
if finle_touch==True:
break
else:
one_lower(i)
elif i == i.upper:
count +=1
print(count) #for debug
else:
count ==0
finle_touch=False
stuff="dsfsfFSfsssfSFSFFSsfssSSsSSSS......."
three_upper(stuff)
print(Truel)
So I have a lot of string on 'stuff' and I like to find 1 lowercase letter that's surrounded by 3 uppercase letter.
But when I run this code I get:
Traceback (most recent call last):
File "C:Python33mypycode.py", line 1294, in <module>
three_upper(stuff)
File "C:Python33mypycode.py", line 1280, in three_upper
if count == 3:
UnboundLocalError: local variable 'count' referenced before assignment
I don't understand why.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…