|
|
8鱼币
我的方法为什么有误差?
- temp = input('请输入字符串:')
- length = len(temp)
- n = length - 3
- if temp[3].islower() and temp[:3].isupper() and temp[4:7].isupper() and (not temp[7].isupper()):
- print(temp[3],end = '')
- for i in range(4,n-1):
- if temp[i].islower() and temp[i-3:i].isupper() and (not temp[i-4].isupper()) and temp[i+1:i+4].isupper() and (not temp[i+4].isupper()):
- print(temp[i],end = '')
- if temp[n-1].islower() and temp[n:].isupper() and temp[n-4:n-1].isupper() and (not temp[n-5].isupper()):
- print(temp[n-1],end = '')
复制代码
得到的最后答案是 uilovefisdhc
题目链接:http://bbs.fishc.com/forum.php?m ... peid%26typeid%3D398
楼主我的问题解决了,和你差不多,你可以看看,答案是对的
a='''那串超长代码'''
whint = len(a)
for each in range(whint):
if a[each].islower(): #如果中间数是小写
if a[each-3].isupper() and a[each-2].isupper() and a[each-1].isupper()\
and a[each+1].isupper() and a[each+2].isupper() and a[each+3].isupper()\
and a[each+4].islower() and a[each-4].islower():
#如果中间数的前三个数是大写,
#中间数的后三个数是大写,
#前面的第四个和后面的第四个是小写(前后3个是大写,那么前后的第4个就是小写)
print(a[each],end='')
|
最佳答案
查看完整内容
楼主我的问题解决了,和你差不多,你可以看看,答案是对的
a='''那串超长代码'''
whint = len(a)
for each in range(whint):
if a[each].islower(): #如果中间数是小写
if a[each-3].isupper() and a[each-2].isupper() and a[each-1].isupper()\
and a[each+1].isupper() and a[each+2].isupper() and a[each+3].isupper()\
and a[each+4].islower() and a[each-4].isl ...
|