python 符号识别_简单符号识别python

这与我一直从Coderbyte“简单符号”得到的错误有关。我试图确定字符串中的一个字符在它的前面和后面是否有特定的字符。我写的东西在我的终端上正常工作,但是我一直从Coderbyte得到同样的错误。在

我是个十足的傻瓜,我的代码一点也不优雅。我知道,我更关心的是错误。在def SimpleSymbols(str_):

str_ = str(str_)

letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

str_list = list(str_)

str_len= len(str_list)

#print str_list

#print str_len

yesno = False

first = True

once = True

dex = -1

for i in str_list:

#print 'step 1'

dex = dex + 1

dex_up = dex + 1

dex_dwn = dex -1

#print 'dex ', dex, 'dex_up ', dex_up, 'dex_dwn ', dex_dwn

if i in letters:

#print 'step 2 its a letter'

if dex_dwn > -1:

#print 'step 3 and its not the first letter'

if dex_up < str_len:

#print 'step 4 and its not the last letter'

if str_list[dex_up] == '+':

#print 'step 5 checked, we got a plus in front'

if str_list[dex_dwn] == '+':

#print 'step 6 checked we got a plus in back'

yesno = True

else:

#print 'step 6 checked, no plus in back'

once = False

else:

#print 'step 5 checked, no plus in front'

once = False

elif dex_up == str_len:

first = False

#print 'step 4 its the last letter'

elif dex_dwn == -1:

#print 'step 3 its the first letter'

first = False

if first and once == True:

return yesno

else:

return False

print SimpleSymbols(raw_input())

这是我从coderbyte得到的错误:

^{pr2}$

谢谢。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值